VUE3按需導入
基礎環(huán)境
? ? 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')