Vue3引入彩色阿里巴巴Iconfont图标

1、下载阿里巴巴矢量图标库代码(Symbol)

在这里插入图片描述

2、main.ts全局引入一下两个文件

import "../src/assets/iconfont/iconfont.js";
import "../src/assets/iconfont/iconfont.css";

3、自定义相应的Iconfont组件

<template>
  ssssssssssssss
  <svg class="icon" aria-hidden="true" :width="fontSize" :height="fontSize">
    <use :xlink:href="class" :fill="color"></use>
  </svg>
</template>

<script setup lang="ts">
import { ref, defineProps } from "vue";
const props = defineProps({
  class: String, //需要添加的字体图标类
  color: {
    //图标颜色
    type: String,
    default: "#444",
  },
  fontSize: {
    //图标大小
    type: [String, Number],
    default: 16,
  },
});
</script>
<style scoped>
.icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
</style>

4、引入组件使用即可

<template>
  <div class="aa">
    舆情管理页面
    <div class="iconfont icon-daohang_jifen-xuanzhong"></div>
   
    <Icon :class="'#icon-test'"></Icon>
  </div>
</template>

<script setup lang="ts">
import Icon from '../../components/Icon/index.vue';

</script>
<style scoped></style>

注:Icon名称前需加#

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值