优化自定义图标功能,修复上线后无法展示自定义图标的问题。 (#1625)

* 修改自定义图标使用方式

* 优化自定义icon功能
This commit is contained in:
奇淼(piexlmax
2024-01-16 22:07:59 +08:00
committed by GitHub
parent d41394c70a
commit a2269bcdd5
6 changed files with 113 additions and 19 deletions
+39
View File
@@ -0,0 +1,39 @@
<template>
<svg
:class="svgClass"
v-bind="$attrs"
:color="color"
>
<use
:xlink:href="'#'+name"
rel="external nofollow"
/>
</svg>
</template>
<script setup>
import { defineProps, computed } from 'vue'
const props = defineProps({
name: {
type: String,
required: true
},
color: {
type: String,
default: 'currentColor'
}
})
const svgClass = computed(() => {
if (props.name) {
return `svg-icon ${props.name}`
}
return 'svg-icon'
})
</script>
<style scoped>
.svg-icon {
@apply w-4 h-4;
fill: currentColor;
vertical-align: middle;
}
</style>