1.首先下载字体图标文件
# NPM
$ npm install @element-plus/icons-vue
# Yarn
$ yarn add @element-plus/icons-vue
# pnpm
$ pnpm install @element-plus/icons-vue
2.之后局部导入(更新后icon是通过组件的形式展示,因此需要局部注册)在main.ts接收该方法,并且传入app即可(app就是createApp(App))
// 统一导入el-icon图标
import { Cellphone, Avatar } from '@element-plus/icons-vue'
const components = [Cellphone, Avatar]
import { App } from 'vue'
// 统一注册el-icon图标
export default function (app: App) {
for (const iconName of components) {
app.component(iconName.name, iconName)
}
}
3.使用