第一种:全局引入
在main.js中加入:
import * as ElementPlusIcons from '@element-plus/icons-vue'/i/导入所有icons
后面调整app写法
const app=createApp(App)
for (const [key, component] of Object.entries(ElementPlusIcons)) {
app.component(key, component)
console.log(key,component)
}
app.mount('#app')
在调用页面使用方法如下:
<el-button type="primary" icon="Edit" round/>
这里注意 icon="Edit" 前面不用加“:”
第二种 局部引入
在调用页面加入:
import {
Check,
Delete,
Edit
} from '@element-plus/icons-vue'
同时需要在data(){return{}}中加入:
return {
Check,
Delete,
Edit
}
在调用时写入:
<el-button type="primary" :icon="Edit" round/>
这里注意 :icon="Edit" 前面需要加“:”
大概原因分析:
前者作为组件调用,后者作为对象变量调用。