zsqy-naive-ui/src/components/SvgIcon/index.vue

42 lines
741 B
Vue
Raw Normal View History

2024-01-05 17:28:54 +08:00
<template>
<svg aria-hidden="true" class="svg-icon">
2024-01-05 17:28:54 +08:00
<use :xlink:href="symbolId" :fill="color" />
</svg>
</template>
<script>
import { defineComponent, computed } from 'vue';
export default defineComponent({
name: 'SvgIcon',
props: {
// 使用的svg图标名称也就是svg文件名
name: {
type: String,
required: true,
},
prefix: {
type: String,
default: 'icon',
},
color: {
type: String,
default: '#333',
},
2024-01-05 17:28:54 +08:00
},
setup(props) {
const symbolId = computed(() => `#${props.prefix}-${props.name}`);
return { symbolId };
2024-01-05 17:28:54 +08:00
},
});
</script>
<style scope>
2024-01-05 17:28:54 +08:00
.svg-icon {
width: 16px;
height: 16px;
/* color: #333; */
fill: currentcolor;
2024-01-05 17:28:54 +08:00
}
</style>