blob: e331a27e15607d57ac9741976b7ad8eea12bb03f [file] [log] [blame]
huibing.xie1f1606f2018-08-20 15:46:55 +08001<template>
2 <svg :class="svgClass" aria-hidden="true">
3 <use :xlink:href="iconName"></use>
4 </svg>
5</template>
6
7<script>
8export default {
9 name: 'svg-icon',
10 props: {
11 iconClass: {
12 type: String,
13 required: true
14 },
15 className: {
16 type: String
17 }
18 },
19 computed: {
20 iconName() {
21 return `#icon-${this.iconClass}`
22 },
23 svgClass() {
24 if (this.className) {
25 return 'svg-icon ' + this.className
26 } else {
27 return 'svg-icon'
28 }
29 }
30 }
31}
32</script>
33
34<style scoped>
35.svg-icon {
36 width: 1em;
37 height: 1em;
38 vertical-align: -0.15em;
39 fill: currentColor;
40 overflow: hidden;
41}
42</style>