From f4d602ae61f729de2f3880df6cf1256487ae69f6 Mon Sep 17 00:00:00 2001 From: K <1175047471@qq.com> Date: Mon, 11 Mar 2024 14:17:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(ApiSelect):=20=E9=A6=96=E6=AC=A1=20onChange?= =?UTF-8?q?=20=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96=E5=88=B0=E7=AC=AC?= =?UTF-8?q?=E4=BA=8C=E4=B8=AA=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Form/src/components/ApiSelect.vue | 1 + src/components/Form/src/helper.ts | 1 - src/hooks/component/useFormItem.ts | 6 ++++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/Form/src/components/ApiSelect.vue b/src/components/Form/src/components/ApiSelect.vue index 224bc07f..1c2e8054 100644 --- a/src/components/Form/src/components/ApiSelect.vue +++ b/src/components/Form/src/components/ApiSelect.vue @@ -126,6 +126,7 @@ function emitChange() { } function handleChange(_, ...args) { + emit('change', args[0] ? args[0].value : undefined) emitData.value = args } diff --git a/src/components/Form/src/helper.ts b/src/components/Form/src/helper.ts index 121980a8..cbd4bfec 100644 --- a/src/components/Form/src/helper.ts +++ b/src/components/Form/src/helper.ts @@ -85,5 +85,4 @@ export const NO_AUTO_LINK_COMPONENTS: ComponentType[] = [ 'AutoComplete', 'RadioButtonGroup', 'ImageUpload', - 'ApiSelect', ] diff --git a/src/hooks/component/useFormItem.ts b/src/hooks/component/useFormItem.ts index 282376d2..652027f8 100644 --- a/src/hooks/component/useFormItem.ts +++ b/src/hooks/component/useFormItem.ts @@ -1,5 +1,5 @@ import type { DeepReadonly, Ref, UnwrapRef, WritableComputedRef } from 'vue' -import { computed, getCurrentInstance, reactive, readonly, toRaw, unref, watchEffect } from 'vue' +import { computed, getCurrentInstance, nextTick, reactive, readonly, toRaw, unref, watchEffect } from 'vue' import { isEqual } from 'lodash-es' @@ -37,7 +37,9 @@ export function useRuleFormItem(props: T, key: keyof T = ' return innerState.value = value as T[keyof T] - emit?.(changeEvent, value, ...(toRaw(unref(emitData)) || [])) + nextTick(() => { + emit?.(changeEvent, value, ...(toRaw(unref(emitData)) || [])) + }) }, })