SvgIcon.vue 734 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <template>
  2. <svg
  3. class="svg-icon"
  4. :class="className"
  5. aria-hidden="true"
  6. :style="{ width: size + 'px', height: size + 'px', fill: color }"
  7. >
  8. <use :href="iconName" />
  9. </svg>
  10. </template>
  11. <script setup>
  12. import { computed } from "vue";
  13. const props = defineProps({
  14. icon: {
  15. type: String,
  16. default: "",
  17. },
  18. className: {
  19. type: String,
  20. default: "",
  21. },
  22. size: {
  23. type: Number,
  24. default: 20,
  25. },
  26. color: {
  27. type: String,
  28. default: "green",
  29. },
  30. });
  31. const iconName = computed(() => `#icon-${props.icon}`);
  32. </script>
  33. <style lang="scss" scoped>
  34. // .svg-icon {
  35. // fill: currentColor;
  36. // }
  37. </style>