Element Plus图标注册

这里只讲全局注册,局部注册,自己百度,不难

关于Element-plus图标的注册

这是官方给的方法
在这里插入图片描述
作为一个新手小白,当然看不懂呀
所以去找视频了
这是up主们给的常规操作,简单易懂
代码地址

import * as ElIcons from '@element-plus/icons-vue'
 
const app = createApp(App)
for (const name in ElIcons){
	app.component(name,(ElIcons as any)[name])
}

但是有一个问题

```

在这里插入图片描述
看见这个了吗?
Unexpected token, expected “,” (36:29)

原因:大意就是说要这个eslintric.js

接下来
处理办法
在这里插入图片描述
一大堆问题,导致俄罗斯套娃
所以,以上废弃,不要刻意去看了,没用

我想说,如果遇到这样的问题的人
不要去想什么问题了,没必要

使用下面这个
代码地址

import * as ElIcons  from '@element-plus/icons-vue'

for (let iconName in ElIcons) {
	app.component(iconName, ElIcons[iconName])
}	

或者,这个

代码地址

import * as ElIcons  from '@element-plus/icons-vue'

for (const iconName in ElIcons) {
  if (Reflect.has(ElIcons, iconName)) {
    const item = ElIcons[iconName]
    app.component(iconName, item)
  }
}

版权声明:本文为weixin_45309354原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。