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
相关推荐
一只小阿乐4 分钟前
java 快速上手开发 2
java·开发语言·前端
nicole bai15 分钟前
dialog封装
前端·javascript·vue.js
高彬24 分钟前
SAP ECC6.0 对接 C# web Services服务
开发语言·前端·c#·sap
小江的记录本25 分钟前
【CSS】CSS 核心:盒模型、BFC/IFC、Flex/Grid 布局、响应式布局、移动端适配(附《思维导图》)
前端·css·面试·前端框架·tensorflow·html5·xss
Coodor26 分钟前
BS架构下在前端读写超高频UHF标签
前端·超高频·rfid读写器web插件·uhf标签
一晌小贪欢30 分钟前
python-第20天:关键字参数与不定长参数
java·开发语言·前端·python·数据可视化·函数参数·python办公
我命由我1234532 分钟前
JS Mock(Mock 拦截请求的前提、Mock 使用、关闭 Mock)
开发语言·前端·javascript·前端框架·html·html5·js
开开心心就好38 分钟前
手机精确倒计时工具悬浮窗口秒数实时显示
android·前端·javascript·jupyter·智能手机·pdf·html
小江的记录本44 分钟前
【HTML】HTML5 新特性、语义化标签、浏览器渲染流程(附《思维导图》)
前端·css·面试·前端框架·html·css3·html5