<template>
  <svg class="svg-icon" aria-hidden="true">
    <image v-if="svgHref" :xlink:href="svgHref" />

    <use v-else :xlink:href="_iconName"/>
<!--    使用 链接 加载 svg-->
  </svg>
</template>

<script>
export default {
  name: 'SvgIcon',
  props: {
    iconClass: {
      type: String,
      default: '',
    },
    svgHref: {
      type: String,
      default: '',
    },
  },
  computed: {
    _iconName () {
      return `#icon-${this.iconClass}`
    },
  },
}
</script>

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