From 5d36b1a5604f72921bf09c16a78e5e287a1ba9d0 Mon Sep 17 00:00:00 2001 From: Jun <33900216+boqingren@users.noreply.github.com> Date: Wed, 29 May 2024 21:56:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E9=87=8D=E7=BD=AE=E5=90=8E=EF=BC=8C=E9=A1=B5=E9=9D=A2=E5=8F=98?= =?UTF-8?q?=E5=8C=96=E4=BA=86=EF=BC=8C=E4=BD=86=E6=98=AF=E7=94=B1=E4=BA=8E?= =?UTF-8?q?=E5=BC=82=E6=AD=A5=E9=97=AE=E9=A2=98=E5=AF=BC=E8=87=B4=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E5=86=85=E9=83=A8=E7=9A=84=E7=8A=B6=E6=80=81=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=8F=8A=E6=97=B6=E5=90=8C=E6=AD=A5=20(#3882)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Form/src/hooks/useForm.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/Form/src/hooks/useForm.ts b/src/components/Form/src/hooks/useForm.ts index bdfcdf0e..5ea52370 100644 --- a/src/components/Form/src/hooks/useForm.ts +++ b/src/components/Form/src/hooks/useForm.ts @@ -78,9 +78,13 @@ export function useForm(props?: Props): UseFormReturnType { form.clearValidate(name); }, - resetFields: async () => { - getForm().then(async (form) => { - await form.resetFields(); + resetFields: () => { + // 修复表单重置后,页面变化了,但是由于异步问题导致表单内部的状态没有及时同步 + return new Promise((resolve) => { + getForm().then(async (form) => { + await form.resetFields(); + resolve(); + }); }); },