vuecli集成webpack时按需引入element plus
按官网流程
1.安装elementplus本体及npm包 npm i unplugin-vue-components unplugin-auto-import -D
cli3+时 没有webpack.config.js或vue.config.js,新建一个vue.config.js文件
2.配置 vue.config.js(这里是vuecli配置方法,其他脚手架需要参考文档)
const AutoImport = require('unplugin-auto-import/webpack') const Components = require('unplugin-vue-components/webpack') const { ElementPlusResolver } = require('unplugin-vue-components/resolvers') module.exports = { configureWebpack: {//来自vuecli文档的webpack合并配置 plugins: [ AutoImport({ resolvers: [ElementPlusResolver()], }), Components({ resolvers: [ElementPlusResolver()], }), ], } }
ps:如果碰到类似格式的错误,
将 :key=“i” 放到 v-for 后面,就可以了