CMVR-BID/src/components/SvgIcon/index.vue
2026-05-25 09:10:10 +08:00

43 lines
705 B
Vue

<template>
<svg
:width="size"
:height="size"
:style="svgStyle"
class="svg-icon"
aria-hidden="true"
>
<use :xlink:href="symbolId" />
</svg>
</template>
<script setup>
import { computed } from 'vue'
const props = defineProps({
name: {
type: String,
required: true
},
size: {
type: [String, Number],
default: 24
},
color: {
type: String,
default: 'currentColor'
},
customStyle: {
type: Object,
default: () => ({})
}
})
const symbolId = computed(() => `#icon-${props.name}`)
const svgStyle = computed(() => ({
verticalAlign: 'middle',
color: props.color, // 用 color 替代 fill
...props.customStyle
}))
</script>