index.vue
766 Bytes
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
38
39
40
41
42
43
44
45
46
47
48
49
<template>
<svg aria-hidden="true"
class="svg-icon"
:style="iconStyle">
<use :xlink:href="iconName" />
</svg>
</template>
<script>
export default {
name: "SvgIcon",
props: {
name: {
type: String,
required: true,
},
size: {
type: [String, Number],
default: "1em",
},
color: {
type: String,
default: "#000",
},
},
computed: {
iconName() {
return `#icon-${this.name}`;
},
iconStyle() {
const size = typeof this.size === "number" ? `${this.size}px` : this.size;
return {
width: size,
height: size,
fill: this.color,
color: this.color,
};
},
},
};
</script>
<style lang="scss" scoped>
.svg-icon {
display: inline-block;
vertical-align: middle;
overflow: hidden;
}
</style>