在 vue3 项目中安装 element ui 插件的问题
Issues installing element ui plugin in vue3 project
大家好,我在 Vue js 上安装插件时遇到问题,所以我尝试在我的项目上安装 Element Ui 插件,安装成功,但在我的 Vs Code 终端中出现了这个:
Compiled with 1 warning
warning in ./src/plugins/element.js
"export 'default' (imported as 'Vue') was not found in 'vue'
而且我无法在本地主机服务器上访问我的项目,它只是一片空白。
我的Main.JS文件
import App from "./App.vue";
import router from "./router";
import store from "./store";
import "./plugins/element.js";
createApp(App)
.use(store)
.use(router)
.mount("#app");
Package.Json
"name": "jargonapp",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.5",
"element-ui": "^2.4.5",
"vue": "^3.0.0",
"vue-router": "^4.0.0-0",
"vuex": "^4.0.0-0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^7.0.0-0",
"vue-cli-plugin-element": "~1.0.1"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}
您似乎将元素 ui 2 与不兼容的 vue 3 一起使用,要使用 Vue 3,您必须安装 element ui plus
卸载当前版本:
npm uninstall element-ui -S
然后安装最新的:
npm i element-plus -S
main.js
最低内容:
import { createApp } from "vue";
import router from "./router";
import store from "./store";
import ElementPlus from "element-plus";
import "element-plus/lib/theme-chalk/index.css";
import App from "./App.vue";
createApp(App)
.use(ElementPlus)
.use(store)
.use(router)
.mount("#app");
大家好,我在 Vue js 上安装插件时遇到问题,所以我尝试在我的项目上安装 Element Ui 插件,安装成功,但在我的 Vs Code 终端中出现了这个:
Compiled with 1 warning
warning in ./src/plugins/element.js "export 'default' (imported as 'Vue') was not found in 'vue'
而且我无法在本地主机服务器上访问我的项目,它只是一片空白。
我的Main.JS文件
import App from "./App.vue";
import router from "./router";
import store from "./store";
import "./plugins/element.js";
createApp(App)
.use(store)
.use(router)
.mount("#app");
Package.Json
"name": "jargonapp",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.5",
"element-ui": "^2.4.5",
"vue": "^3.0.0",
"vue-router": "^4.0.0-0",
"vuex": "^4.0.0-0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^7.0.0-0",
"vue-cli-plugin-element": "~1.0.1"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}
您似乎将元素 ui 2 与不兼容的 vue 3 一起使用,要使用 Vue 3,您必须安装 element ui plus
卸载当前版本:
npm uninstall element-ui -S
然后安装最新的:
npm i element-plus -S
main.js
最低内容:
import { createApp } from "vue";
import router from "./router";
import store from "./store";
import ElementPlus from "element-plus";
import "element-plus/lib/theme-chalk/index.css";
import App from "./App.vue";
createApp(App)
.use(ElementPlus)
.use(store)
.use(router)
.mount("#app");