CMVR-IOT-UI/src/components/SvgIcon/index.vue

43 lines
705 B
Vue
Raw Normal View History

2025-08-21 14:11:58 +08:00
<template>
2026-05-25 09:10:10 +08:00
<svg
:width="size"
:height="size"
:style="svgStyle"
class="svg-icon"
aria-hidden="true"
>
<use :xlink:href="symbolId" />
2025-08-21 14:11:58 +08:00
</svg>
</template>
2026-05-25 09:10:10 +08:00
<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'
2025-08-21 14:11:58 +08:00
},
2026-05-25 09:10:10 +08:00
customStyle: {
type: Object,
default: () => ({})
2025-08-21 14:11:58 +08:00
}
})
2026-05-25 09:10:10 +08:00
const symbolId = computed(() => `#icon-${props.name}`)
2025-08-21 14:11:58 +08:00
2026-05-25 09:10:10 +08:00
const svgStyle = computed(() => ({
verticalAlign: 'middle',
color: props.color, // 用 color 替代 fill
...props.customStyle
}))
</script>