index.vue 471 字节
Newer Older
P
init  
Pan 已提交
1
<template>
P
Pan 已提交
2
  <svg class="svg-icon" aria-hidden="true">
P
init  
Pan 已提交
3 4 5 6 7
    <use :xlink:href="iconName"></use>
  </svg>
</template>

<script>
P
Pan 已提交
8
export default {
P
Pan 已提交
9
  name: 'svg-icon',
P
Pan 已提交
10 11 12 13 14 15 16 17 18
  props: {
    iconClass: {
      type: String,
      required: true
    }
  },
  computed: {
    iconName() {
      return `#icon-${this.iconClass}`
P
init  
Pan 已提交
19 20
    }
  }
P
Pan 已提交
21
}
P
init  
Pan 已提交
22
</script>
P
Pan 已提交
23 24 25 26 27 28 29 30 31 32

<style scoped>
.svg-icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
</style>