SIcon2.js 903 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const n = `<template>
  2. <component :is="name" :class="name" :style="{ fontSize: size + 'px', color: cor }" />
  3. </template>
  4. <script setup>
  5. import { ref, watch } from 'vue'
  6. const props = defineProps({
  7. // 图标名(antd 图标或内置业务图标)
  8. name: {
  9. type: String,
  10. required: true
  11. },
  12. // 图标尺寸,单位 px
  13. size: {
  14. type: Number,
  15. default: 16
  16. },
  17. // 图标颜色,默认继承文字颜色
  18. color: {
  19. type: String,
  20. default: ''
  21. }
  22. })
  23. const cor = ref('var(--s-color)')
  24. watch(
  25. () => props.color,
  26. (cr) => {
  27. cor.value = cr || 'var(--s-color)'
  28. },
  29. { immediate: true }
  30. )
  31. <\/script>
  32. <style lang="less" scoped>
  33. .icon-list {
  34. width: 100%;
  35. display: flex;
  36. justify-content: flex-start;
  37. align-items: flex-start;
  38. flex-wrap: wrap;
  39. .item-icon {
  40. margin: 16px;
  41. cursor: pointer;
  42. font-size: 28px;
  43. }
  44. }
  45. </style>
  46. `;
  47. export {
  48. n as default
  49. };