vite-plugin-svg-icons icon indicating copy to clipboard operation
vite-plugin-svg-icons copied to clipboard

font-size 无效

Open geng130127 opened this issue 3 years ago • 3 comments

svg设置font-size无效

geng130127 avatar May 07 '22 12:05 geng130127

svg设置font-size无效

svg 是通过直接设置宽高控制大小

我的做法:

<!-- SvgIcon.vue -->
<template>
  <svg class="icon" aria-hidden="true" :width="size" :height="size">
    <use :xlink:href="`#i-${icon}`" :fill="color ? color : '#333'" />
  </svg>
</template>

<script setup>
defineProps({
  icon: {
    type: String,
    required: true
  },
  color: {
    type: String,
    default: ''
  },
  size: {
    type: Number,
    default: 32
  }
})
</script>

<!-- 调用 -->
<svg-icon :icon="iconName" :color="iconColor" :size="iconSize" />

仅供参考。

xiaofuyesnew avatar Jun 10 '22 09:06 xiaofuyesnew

组件结尾部分加上这段:

<style scoped>
svg {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
</style>

vimcaw avatar Sep 06 '22 07:09 vimcaw

组件结尾部分加上这段:

<style scoped>
svg {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
</style>

完美的解决办法

geng130127 avatar Sep 06 '22 07:09 geng130127