我一直在使用“element-ui”,现在转向新版本的 Vue3。 似乎他们发布了一个名为“element-plus”的新版本,但教程没有更新。
import Vue from 'vue'; // not working in Vue3
import ElementUI from 'element-plus';
import 'element-ui/lib/theme-chalk/index.css';
...
Vue.use(ElementUI); // no "Vue" in Vue3 anymore
...
createApp(App).mount('#app') // the new project creation
https://element-plus.org/#/en-US/component/quickstart
有人成功地做到了并且有效吗?
最佳答案
如果您使用的是 vue 3,则需要从“element-plus/...”文件夹中导入 createApp
和 css。然后你使用导入的 vue 函数实例化你的 app
,基本上你将你的主要应用程序组件作为参数传递给该函数:
import { createApp } from 'vue'
import App from './YourMainApp.vue'
import ElementPlus from 'element-plus'
import 'element-plus/lib/theme-chalk/index.css'
let app = createApp(App)
app.use(ElementPlus)
app.mount('#app')
关于vuejs2 - 如何在Vue3项目中添加element-ui(现在叫element-plus)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64134028/