Commit 447fd2ee63ef8f3bdfdca54d9a8fa728dcb22c47

Authored by ww
1 parent 77fe68ab

fix: 修复icon选择器切换后图标未更新

... ... @@ -3,18 +3,20 @@
3 3 import IconData from '/@/components/Icon/data/iconfont.data';
4 4 import { SvgIcon } from '/@/components/Icon';
5 5 import { computed } from '@vue/reactivity';
6   - import { onMounted, unref } from 'vue';
  6 + import { onMounted } from 'vue';
7 7
8   - const props = defineProps<{
9   - value?: string;
10   - color?: string;
11   - }>();
  8 + const props = withDefaults(
  9 + defineProps<{
  10 + value?: string;
  11 + color?: string;
  12 + }>(),
  13 + {
  14 + value: 'shuiwen',
  15 + }
  16 + );
12 17 const emit = defineEmits(['update:value']);
13 18 const iconList = IconData.icons;
14 19 const [register, { openDrawer, closeDrawer }] = useDrawer();
15   - const getIcon = computed(() => {
16   - return props.value || 'shuiwen';
17   - });
18 20
19 21 const getColor = computed(() => {
20 22 return props.color || '#377DFF';
... ... @@ -30,14 +32,13 @@
30 32 };
31 33
32 34 onMounted(() => {
33   - emit('update:value', unref(getIcon));
  35 + emit('update:value', props.value);
34 36 });
35 37 </script>
36 38
37 39 <template>
38 40 <SvgIcon
39   - :name="getIcon"
40   - :icon="getIcon"
  41 + :name="value"
41 42 prefix="iconfont"
42 43 class="cursor-pointer !w-6 !h-6"
43 44 :style="{ color: getColor }"
... ...