From 79571477cf578eed30b2d39b0ef7ce3715b4b8d0 Mon Sep 17 00:00:00 2001 From: zhangdaiscott Date: Tue, 8 Nov 2022 22:00:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E5=8D=95=E6=A0=A1=E9=AA=8C=E6=9C=89?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D=EF=BC=8C=E5=BF=85=E5=A1=AB?= =?UTF-8?q?=E7=9A=84form=E7=9A=84validate=E6=A0=A1=E9=AA=8C=E5=8F=8D?= =?UTF-8?q?=E8=BF=87=E6=9D=A5=E4=BA=86=20#issues/4189?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/component/useFormItem.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hooks/component/useFormItem.ts b/src/hooks/component/useFormItem.ts index 900a073..6885bee 100644 --- a/src/hooks/component/useFormItem.ts +++ b/src/hooks/component/useFormItem.ts @@ -1,5 +1,6 @@ import type { UnwrapRef, Ref, WritableComputedRef, DeepReadonly } from 'vue'; import { reactive, readonly, computed, getCurrentInstance, watchEffect, unref, nextTick, toRaw } from 'vue'; +import {Form} from "ant-design-vue"; import { isEqual } from 'lodash-es'; export function useRuleFormItem>( @@ -11,6 +12,7 @@ export function useRuleFormItem(props: T, key: keyof T = 'value', changeEvent = 'change', emitData?: Ref) { const instance = getCurrentInstance(); const emit = instance?.emit; + const formItemContext = Form.useInjectFormItemContext(); const innerState = reactive({ value: props[key], @@ -37,6 +39,9 @@ export function useRuleFormItem(props: T, key: keyof T = ' innerState.value = value as T[keyof T]; nextTick(() => { emit?.(changeEvent, value, ...(toRaw(unref(emitData)) || [])); + // https://antdv.com/docs/vue/migration-v3-cn + // antDv3升级后需要调用这个方法更新校验的值 + nextTick(() => formItemContext.onFieldChange()); }); }, });