Commit 447fd2ee63ef8f3bdfdca54d9a8fa728dcb22c47

Authored by ww
1 parent 77fe68ab

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

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