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
相关推荐
_AaronWong18 小时前
Electron 实现仿豆包划词取词功能:从 AI 生成到落地踩坑记
前端·javascript·vue.js
cxxcode18 小时前
I/O 多路复用:从浏览器到 Linux 内核
前端
用户54330814419418 小时前
AI 时代,前端逆向的门槛已经低到离谱 — 以 Upwork 为例
前端
JarvanMo18 小时前
Flutter 版本的 material_ui 已经上架 pub.dev 啦!快来抢先体验吧。
前端
恋猫de小郭18 小时前
AI 可以让 WIFI 实现监控室内人体位置和姿态,无需摄像头?
前端·人工智能·ai编程
哀木18 小时前
给自己整一个 claude code,解锁编程新姿势
前端
程序员鱼皮19 小时前
GitHub 关注突破 2w,我总结了 10 个涨星涨粉技巧!
前端·后端·github
UrbanJazzerati19 小时前
Vue3 父子组件通信完全指南
前端·面试
是一碗螺丝粉19 小时前
5分钟上手LangChain.js:用DeepSeek给你的App加上AI能力
前端·人工智能·langchain
wuhen_n19 小时前
双端 Diff 算法详解
前端·javascript·vue.js