vue3增加阿里云字体图标

在现有的字体里增加一个自定义的图标

一、阿里云字体所在目录

二、在阿里云网站里找到你想要的图标

丢到svg目录下

 也可以直接复制SVG代码

注意:因为找的图标有的是有默认颜色的不是纯颜色。所以要设置

如下中fill="#CCCCCC"  就是有个默认灰色。将其用stroke="#979797" 替换或是删除

<svg t="1751952413202" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="19125" width="200" height="200"><path d="M903.712 853.952c-45.184-136.128-158.976-235.552-296.992-267.2A223.808 223.808 0 0 0 736 384a224 224 0 1 0-448 0 223.872 223.872 0 0 0 129.312 202.784c-138.016 31.584-251.808 131.04-297.024 267.136a32.032 32.032 0 0 0 60.736 20.16C227.552 734.048 360.576 640 512 640c151.488 0 284.48 94.048 330.944 234.048a32 32 0 0 0 60.768-20.096zM352 384c0-88.224 71.776-160 160-160 88.192 0 160 71.776 160 160s-71.776 160-160 160-160-71.776-160-160z" fill="#ADADAD" p-id="19126"></path></svg>

转为

 三、使用方法

 <svg-icon  icon-class="simple-user" :color="scope.row.sex==='1'? '#409EFF':'#F56C6C'"></svg-icon>

 期中simple-user就是自定义的图片,color是自定义的颜色(前提是纯色svg)

四、期中<svg-icon组件代码

<template>
  <svg :class="svgClass" aria-hidden="true">
    <use :xlink:href="iconName" :fill="color" />
  </svg>
</template>

<script>
// 引入阿里云字体图标css
import "assets/font/iconfont.css";
import "assets/font/iconfont.js";
export default defineComponent({
  props: {
    iconClass: {
      type: String,
      required: true
    },
    className: {
      type: String,
      default: ''
    },
    color: {
      type: String,
      default: ''
    },
  },
  setup(props) {
    return {
      iconName: computed(() => `#icon-${props.iconClass}`),
      // iconName: computed(() => `#${props.iconClass}`),
      svgClass: computed(() => {
        if (props.className) {
          return `svg-icon ${props.className}`
        }
        return 'svg-icon'
      })
    }
  }
})
</script>

<style scope lang="scss">
.sub-el-icon,
.nav-icon {
  display: inline-block;
  font-size: 15px;
  margin-right: 12px;
  position: relative;
}

.svg-icon {
  width: 1em;
  height: 1em;
  position: relative;
  fill: currentColor;
  vertical-align: -2px;
}

</style>

五、最终效果

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

十方天士

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值