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
相关推荐
羊锦磊8 分钟前
[ vue 前端框架 ] 基本用法和vue.cli脚手架搭建
前端·vue.js·前端框架
brzhang15 分钟前
高通把Arduino买了,你的“小破板”要变“AI核弹”了?
前端·后端·架构
她说..20 分钟前
通过git拉取前端项目
java·前端·git·vscode·拉取代码
智能化咨询29 分钟前
玩转ClaudeCode:通过Chrome DevTools MCP实现高级调试与反反爬策略
前端·chrome·chrome devtools
Roadinforest1 小时前
水墨风鼠标效果实现
前端·javascript·vue.js
银嘟嘟左卫门1 小时前
上手 Rokid JSAR:新手也能快速入门的 AR 开发之旅
前端
右子1 小时前
HTML Canvas API 技术简述与关系性指南
前端·javascript·canvas
Lotzinfly1 小时前
10个JavaScript浏览器API奇淫技巧你需要掌握😏😏😏
前端·javascript·面试
合肥烂南瓜1 小时前
浏览器的事件循环EventLoop
前端·面试
golang学习记1 小时前
从0死磕全栈之Next.js after 函数详解:在响应完成后执行异步任务
前端