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
相关推荐
PedroQue992 分钟前
v0.2.0 架构升级:class + reactive 重塑状态管理
前端·uni-app
鶴哥只手遮天2 分钟前
Angular 22 源码级深度解析-第 02 章 编译链路总览:从模板字符串到 `ɵɵ` 指令
前端·开源·angular.js
尘世中一位迷途小书童2 分钟前
别再堆万字 Prompt:用 Agent Skills 给团队写一个「前端 Review」Skill
前端·ai编程·cursor
aixingpan5 分钟前
aixingpan.cn API开发文档:api_docs_bichart_common2接口指南
前端·php
super_Omni8 分钟前
text/PDF/Word → 解析成纯文本 → 分词 → 词表匹配 → 加权打分 → 低于阈值
前端·chrome
阶进遐12 分钟前
浏览器工具自制指南·对话导出(3):消息池设计
前端
SameX16 分钟前
HarmonyOS 用 relationalStore 做阅读统计 App —— 5 张表背后的 5 个 schema 决策
前端
LV技术派28 分钟前
【成为 AI Native Builder · 02】什么是 AI Native Builder:一个人 + AI,交付完整闭环
前端·程序员·ai编程
#麻辣小龙虾#1 小时前
网页布局css中flex+margin的组合布局技巧
开发语言·前端·javascript
叼烟扛炮1 小时前
Linux 学习笔记(四十五):Web 安全基石——Cookie、Session 与 HTTPS 原理解析
linux·前端·网络·笔记·学习·tcp/ip·安全