官网文档:快速开始 | Element Plus
webpack配置
// webpack.config.js
const AutoImport = require('unplugin-auto-import/webpack')
const Components = require('unplugin-vue-components/webpack')
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers')
module.exports = {
// ...
plugins: [
AutoImport({
resolvers: [ElementPlusResolver()],
}),
Components({
resolvers: [ElementPlusResolver()],
}),
],
}
运行结果:TypeError: AutoImport is not a function
解决方式:安装低版本nplugin-auto-import
yarn add unplugin-auto-import@0.16.1 -D
关联问题Components is not a function参考
element-plus按需引入报错Components is not a function-CSDN博客