ant design分享记录-icon图标自定义菜单图标

ant design分享-icon图标自定义菜单图标

本过程使用 iconfont.cn上的

在这里插入图片描述

设置icon前缀

import { Icon } from 'ant-design-vue';
import Vue from 'vue'

const JihaoIcon = Icon.createFromIconfontCN({
    scriptUrl:'//at.alicdn.com/t/xxxxxxxxxxxxxxxx.js'
})

Vue.component('jihao-icon', JihaoIcon)
export default JihaoIcon

在src/components/Menu/menu.js里

修改菜单图标
renderIcon (icon) {
      if (icon === 'none' || icon === undefined) {
        return null
      }
      const props = {}
      typeof (icon) === 'object' ? props.component = icon : props.type = icon
      if (props.type && props.type.startsWith('icon_')) {
        return (
          <JihaoIcon type={props.type}/>
        )
      }
      return (
        <Icon {... { props } }/>
      )
    },

其他地方图标添加方式

<a-button @click="handleRemove(record)" style="padding: 0 6px;font-size: 12px;height: 26px;">
  <jihao-icon style="font-size: 13px;" title="删除" type="icon_delete_device"></jihao-icon>
  <span style="font-size: 12px;">删除</span>
</a-button>
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值