12345678910111213141516171819202122232425262728293031323334 |
- <script setup lang="ts">
- import type { CSSProperties } from 'vue'
- const props = withDefaults(
- defineProps<{
- name: string
- prefix?: string
- color?: string
- size?: number
- }>(),
- {
- prefix: 'icon',
- size: 16
- }
- )
- const symbolId = computed(() => `#${props.prefix}-${props.name}`)
- const fill = computed(() => (props.color ? props.color : 'currentColor'))
- const getStyle = computed((): CSSProperties => {
- const s = `${`${props.size}`.replace('px', '')}px`
- return {
- width: s,
- height: s
- }
- })
- </script>
- <template>
- <svg :style="getStyle" aria-hidden="true">
- <use :xlink:href="symbolId" :fill="fill" />
- </svg>
- </template>
- <style scoped lang="less"></style>
|