Files
my_sys/VScode/src/components/base/svg-icon/index.vue
DelLevin-Home 71de5323aa 首次提交
2026-01-13 10:06:37 +08:00

39 lines
959 B
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<svg aria-hidden="true" :class="`iconfont ${className}`" :style="`width:${width};height:${height};color:${color};${style}`">
<use :xlink:href="symbolId" />
</svg>
</template>
<script lang="ts">
import { computed, defineComponent } from "vue";
/**
* 自定义svg图标可自行将svg图标下载后存放在/src/assets/icons/svg目录下
* `使用方法:<svg-icon name="earth" color="red"></svg-icon>`
*/
export default defineComponent({
name: "SvgIcon",
props: {
prefix: {
type: String,
default: "icon"
},
name: {
type: String,
required: true
},
color: {
type: String,
default: ""
},
width: String,
height: String,
className: { type: String, default: "" },
style: { type: String, default: "" }
},
setup(props) {
const symbolId = computed(() => `#${props.prefix}-${props.name.replace("icon-", "")}`);
return { symbolId };
}
});
</script>