index.vue 694 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <template>
  2. <svg :class="svgClass" aria-hidden="true">
  3. <use :xlink:href="iconName"/>
  4. </svg>
  5. </template>
  6. <script>
  7. export default {
  8. name: 'SvgIcon',
  9. props: {
  10. iconClass: {
  11. type: String,
  12. required: true
  13. },
  14. className: {
  15. type: String,
  16. default: ''
  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. <style scoped>
  34. .svg-icon {
  35. width: 2em;
  36. height: 2em;
  37. vertical-align: -0.15em;
  38. fill: #F0F2F5;
  39. overflow: hidden;
  40. vertical-align: middle;
  41. }
  42. </style>