1.下载unplugin-vue-components,unplugin-auto-import 包
npm i -D unplugin-vue-components unplugin-auto-import
2.vite.config.js 文件中配置
1 import AutoImport from 'unplugin-auto-import/vite' 2 import Components from 'unplugin-vue-components/vite' 3 import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
1 plugins: [ 2 // 按需引入Element-plus 3 AutoImport({ 4 resolvers: [ElementPlusResolver({ importStyle: false })] 5 }), 6 Components({ 7 resolvers: [ElementPlusResolver()] 8 }) 9 ],
标签:vue,auto,Element,unplugin,plus,components,import,vite From: https://www.cnblogs.com/tan253/p/17729609.html