Browse Source

fix: 修复`:[modelValueProp]="currentSelect"`不生效的问题

pull/8332/head
zhongming4762 1 month ago
parent
commit
1b1441e04a
  1. 24
      packages/effects/common-ui/src/components/icon-picker/icon-picker.vue

24
packages/effects/common-ui/src/components/icon-picker/icon-picker.vue

@ -1,7 +1,14 @@
<script setup lang="ts"> <script setup lang="ts">
import type { IconPickerProps } from './types'; import type { IconPickerProps } from './types';
import { computed, ref, useAttrs, watch, watchEffect } from 'vue'; import {
computed,
onBeforeUpdate,
ref,
useAttrs,
watch,
watchEffect,
} from 'vue';
import { usePagination } from '@vben/hooks'; import { usePagination } from '@vben/hooks';
import { EmptyIcon, Grip, listIcons } from '@vben/icons'; import { EmptyIcon, Grip, listIcons } from '@vben/icons';
@ -100,7 +107,17 @@ const { paginationList, total, setCurrentPage, currentPage } = usePagination(
); );
watchEffect(() => { watchEffect(() => {
currentSelect.value = modelValue.value; currentSelect.value =
props.modelValueProp === 'modelValue'
? modelValue.value
: ((attrs[props.modelValueProp] as string) ?? '');
});
onBeforeUpdate(() => {
if (props.modelValueProp !== 'modelValue') {
currentSelect.value =
(attrs[props.modelValueProp] as string | undefined) ?? '';
}
}); });
watch( watch(
@ -111,8 +128,7 @@ watch(
); );
const handleClick = (icon: string) => { const handleClick = (icon: string) => {
currentSelect.value = icon; updateCurrentSelect(icon);
modelValue.value = icon;
close(); close();
}; };

Loading…
Cancel
Save