element-plus按需引入报错Components is not a function
官网文档:快速开始 | 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: Components is not a function
解决方式:安装低版本unplugin-vue-components
yarn add unplugin-vue-components@0.25.0 -D