element-plus按需引入报错IconsResolver is not a function

官网文档:element-plus-best-practices/vite.config.ts at db2dfc983ccda5570033a0ac608a1bd9d9a7f658 · sxzz/element-plus-best-practices · GitHubElement Plus Best Practices 最佳实践. Contribute to sxzz/element-plus-best-practices development by creating an account on GitHub.https://github.com/sxzz/element-plus-best-practices/blob/db2dfc983ccda5570033a0ac608a1bd9d9a7f658/vite.config.ts#L21-L58

webpack配置

javascript 复制代码
// webpack.config.js
const IconsResolver = require("unplugin-icons/resolver");

module.exports = {
  // ...
  configureWebpack: (config) => {
    // ...
    config.plugins.push(
      AutoImport({
        resolvers: [
          // 自动导入图标组件
          IconsResolver({
            prefix: "Icon",
          }),
          // ...
        ],
      })
    );
    config.plugins.push(
      Components({
        resolvers: [
          // 自动注册图标组件
          IconsResolver({
            enabledCollections: ["ep"],
          }),
          // ...
        ],
      })
    );
  }
}

运行结果:TypeError: IconsResolver is not a function

解决方式:安装低版本unplugin-icons

bash 复制代码
yarn add unplugin-icons@0.14.1 -D
相关推荐
之歆1 天前
DAY12_CSS3选择器全攻略 + 盒子新特性完全指南(下)
前端·javascript·css3
kyriewen111 天前
代码写成一锅粥?3个设计模式让你的项目“起死回生”
开发语言·前端·javascript·设计模式·ecmascript
光影少年1 天前
react函数组件、类组件、纯组件、受控/非受控组件
前端·react.js·掘金·金石计划
程序员包打听1 天前
MoonBit 是什么?给第一次听说这门语言的你
前端·后端
Rkgua1 天前
CSS动画效果
前端·css
Rkgua1 天前
Flexbox 与 Grid 布局
前端·css
C澒1 天前
面向前端自测的智能 Mock 系统架构设计与全流程落地
前端·ai
西洼工作室1 天前
python邮箱令牌/点击验证、邮箱验证码实现
前端·python
iCxhust1 天前
在 emu8086 中可以直接编译运行的完整汇编程序,演示数组的定义、遍历、求和、求最大值。
开发语言·前端·javascript·汇编·单片机·嵌入式硬件·算法