镇楼图
按需引入
安装element-plus
cnpm install element-plus --save
安装按需导入
cnpm install -D unplugin-vue-components unplugin-auto-import
修改vite.config.js配置按需加载
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
plugins: [
vue(),
AutoImport({
resolvers: [ElementPlusResolver()],
}),
Components({
resolvers: [ElementPlusResolver()],
})
],
完整引用
安装element-plus
cnpm install element-plus --save
main.js
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
app.use(ElementPlus)