vue中使用iconfont图标字体svg

vue中使用iconfont图标字体svg

徐徐
前端
发布于2024-08-27 21:58:31
🌺前言
vue中使用iconfont图标字体svg

封装iconfont组件

vue
<template>
  <svg
    class="icon"
    aria-hidden="true"
    :style="{
      width: `${width}px`,
      height: `${height}px`,
    }"
  >
    <use :xlink:href="'#' + iconClass" v-bind="attrs"></use>
  </svg>
</template>

<script lang="ts" setup>
const props = defineProps({
  iconClass: {
    required: true,
    type: String,
  },
  width: {
    type: [String, Number],
    required: true,
  },
  height: {
    type: [String, Number],
    required: true,
  },
});
const { iconClass, width, height } = toRefs(props);
const attrs = useAttrs();
</script>

<style lang="scss" scoped></style>
文章最后更新于 2024-08-27 22:01:53
留言
暂无数据

~~空空如也