1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| <template> <svg aria-hidden="false" class="icon"> <use :xlink:href="symbolId" :fill="color" /> </svg> </template>
<script lang="ts"> import { computed, defineComponent } from 'vue' export default defineComponent({ name: 'SvgIcon', props: { prefix: { type: String, default: 'icon', }, name: { type: String, required: true, }, color: { type: String, default: '#333', }, }, setup(props: any) { const symbolId = computed(() => `#${props.prefix}-${props.name}`) return { symbolId } }, }) </script>
<style scoped lang="scss"> .icon { width: 100%; height: 100%; } </style>
|