2024-01-05 17:28:54 +08:00
|
|
|
|
<template>
|
2024-02-05 10:28:35 +08:00
|
|
|
|
<svg aria-hidden="true" class="svg-icon">
|
2024-01-05 17:28:54 +08:00
|
|
|
|
<use :xlink:href="symbolId" :fill="color" />
|
|
|
|
|
|
</svg>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
2024-02-05 10:28:35 +08:00
|
|
|
|
<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
|
|
|
|
},
|
2024-02-05 10:28:35 +08:00
|
|
|
|
setup(props) {
|
|
|
|
|
|
const symbolId = computed(() => `#${props.prefix}-${props.name}`);
|
|
|
|
|
|
return { symbolId };
|
2024-01-05 17:28:54 +08:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
</script>
|
2024-02-05 10:28:35 +08:00
|
|
|
|
<style scope>
|
2024-01-05 17:28:54 +08:00
|
|
|
|
.svg-icon {
|
2024-02-05 10:28:35 +08:00
|
|
|
|
width: 16px;
|
|
|
|
|
|
height: 16px;
|
|
|
|
|
|
|
|
|
|
|
|
/* color: #333; */
|
|
|
|
|
|
fill: currentcolor;
|
2024-01-05 17:28:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
</style>
|