IconFont.vue 1.33 KB
<!--
 * @Date: 2026-01-29 21:30:20
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2026-01-30 17:16:13
 * @FilePath: /manulife-weapp/src/components/IconFont.vue
 * @Description: 图标字体组件
-->
<template>
  <component :is="iconComponent" v-if="iconComponent" :size="size" :class="customClass" :color="color" />
</template>

<script setup>
import { computed } from 'vue';
import {
  Cart,
  Category,
  Check,
  Checklist,
  Clock,
  Download,
  Edit,
  Find,
  Home,
  Issue,
  Link,
  Loading,
  Location,
  My,
  Order,
  People,
  PlayCircleFill,
  Refresh,
  RectRight,
  RectLeft,
  Search,
  Service,
  Star,
  StarFill,
  Top,
  Photograph,
  Del,
  Close,
} from '@nutui/icons-vue-taro';

const props = defineProps({
  name: {
    type: String,
    required: true
  },
  size: {
    type: [String, Number],
    default: ''
  },
  color: {
    type: String,
    default: ''
  },
  customClass: {
    type: String,
    default: ''
  }
});

const icons = {
  Cart,
  Category,
  Check,
  Checklist,
  Clock,
  Download,
  Edit,
  Find,
  Home,
  Issue,
  Link,
  Loading,
  Location,
  My,
  Order,
  People,
  PlayCircleFill,
  Refresh,
  RectRight,
  RectLeft,
  Search,
  Service,
  Star,
  StarFill,
  Top,
  Photograph,
  Del,
  Close,
};

const iconComponent = computed(() => {
  return icons[props.name] || null;
});
</script>