VUE3按需导入
基础环境
vue 3
element-plus 2
vue-router 4
参考文档
配置
引入组件
npm install-D unplugin-vue-components unplugin-auto-import
npm install-D unplugin-element-plus
添加组件配置
vue.config.js
configureWebpack: {
plugins: [
AutoImport({
resolvers: [ElementPlusResolver({ importStyle: false })],
}),
Components({
resolvers: [ElementPlusResolver()],
}),
],
}
注释全局引入,但是要引入样式
main.js
import { createApp } from 'vue'
// import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router'
const app = createApp(App)
// app.use(ElementPlus, { zIndex: 2000 })
app.use(router)
app.mount('#app')