element-plus 更新 1.2.0版本后 @element-plus/icons 的使用
element-plus1.2.0 组件内的 Font Icon 向 SVG Icon 迁移,正式版本Font Icon将被弃用
@element-plus/icons 的使用
element-plus 升级后 需要对应的更改
安装|更新
1
| yarn add element-plus @element-plus/icons-vue
|
plugins/elementPlus.ts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| import ElementPlus from 'element-plus' import locale from 'element-plus/lib/locale/lang/zh-cn.js'
import 'element-plus/dist/index.css' import 'dayjs/locale/zh-cn' import * as icons from '@element-plus/icons-vue'
export default function (app) { app.use(ElementPlus, { locale }) }
export function installIcon (app) { Object.keys(icons).forEach(key => { app.component(key, icons[key]) }) }
|
main.ts
1 2 3 4 5 6
| import ElementPlus, {installIcon} from './plugins/elementPlus'
const app = createApp(App)
installIcon(app)
|
ICON的使用
1 2 3
| <el-icon> <add-location /> </el-icon>
|
如有问题可联系 Email:afacode@outlook.com 或 微信:afacode