1. 没有安装 element-plus/icons 的,安装命令如下:
npm install @element-plus/icons-vue
2. main.js 引入(我比较懒,全部引入。) :
import { createApp } from 'vue'
import App from './App.vue'
import router from './router' // 导入 路由
import store from './store' // 导入 vuex
import ElementPlus from 'element-plus' // 导入Element Plus
import 'element-plus/theme-chalk/index.css' // 导入Element Plus css
// 导入 icon
import * as ElIconList from '@element-plus/icons-vue'
const app = createApp(App).use(router).use(store).use(ElementPlus)
// 注册icon
for (const name in ElIconList) {
app.component(name, ElIconList[name])
}
app.mount('#app')
使用 eg:
<el-button icon="Rank" />
展示效果: