index.vue 792 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <svg
  3. :class="getClassName"
  4. aria-hidden="true"
  5. >
  6. <use :xlink:href="getName" />
  7. </svg>
  8. </template>
  9. <script>
  10. export default {
  11. name: 'IconSvg',
  12. props: {
  13. name: {
  14. type: String,
  15. required: true
  16. },
  17. className: {
  18. type: String,
  19. default: ''
  20. }
  21. },
  22. computed: {
  23. getName () {
  24. return `#icon-${this.name}`
  25. },
  26. getClassName () {
  27. return [
  28. 'icon-svg',
  29. `icon-svg__${this.name}`,
  30. this.className && /\S/.test(this.className) ? `${this.className}` : ''
  31. ]
  32. }
  33. }
  34. }
  35. </script>
  36. <style scoped>
  37. .icon-svg {
  38. width: 18px;
  39. height: 18px;
  40. vertical-align: middle;
  41. fill: currentColor;
  42. overflow: hidden;
  43. mask-size: cover!important;
  44. display: inline-block;
  45. }
  46. </style>