
vue3中引入element-plus的Icon
最近使用element-plus开发项目,发现element-plus废弃了Font Icon 使用了 SVG Icon。需要在全局注册组件,或者按需引用。
安装#
使用包管理器#
$ npm install @element-plus/icons-vue
$ yarn add @element-plus/icons-vue
$ pnpm install @element-plus/icons-vue
**在main里面导入引入icon**
import \* as Icons from '@element-plus/icons-vue'**// 注册Icons 全局组件**
Object.keys(Icons).forEach(key => {
app.component(key, Icons[key])
})**(House )名字引用是你要使用图标的名字,导入是首字母大写**
import { House } from '@element-plus/icons-vue'// 在vue文件使用
<el-icon><house /></el-icon>原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。