From 3dd28ad243b5bb80e43bf74d15b1c5b1f39bcfbe Mon Sep 17 00:00:00 2001 From: RUNZE LU <36724300+lurunze1226@users.noreply.github.com> Date: Thu, 12 Oct 2023 19:06:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Form=E7=BB=84=E4=BB=B6=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=B7=B3=E8=BD=AC=E4=BA=8B=E4=BB=B6=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E4=BC=9A=E5=AF=BC=E8=87=B4=E6=8C=81=E4=B9=85=E5=8C=96?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=97=A0=E6=B3=95=E6=B8=85=E9=99=A4=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#8354)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-core/src/renderers/Form.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/amis-core/src/renderers/Form.tsx b/packages/amis-core/src/renderers/Form.tsx index 3f88f3910..e33734f60 100644 --- a/packages/amis-core/src/renderers/Form.tsx +++ b/packages/amis-core/src/renderers/Form.tsx @@ -1154,6 +1154,8 @@ export default class Form extends React.Component { if (target) { this.submitToTarget(filterTarget(target, values), values); + /** 可能配置页面跳转事件,页面路由变化导致persistKey不一致,无法清除持久化数据,所以提交成功事件之前先清理一下 */ + clearPersistDataAfterSubmit && store.clearLocalPersistData(); dispatchEvent('submitSucc', createObject(this.props.data, values)); } else if (action.actionType === 'reload') { action.target && @@ -1185,6 +1187,7 @@ export default class Form extends React.Component { ? filter(saveFailed, store.data) : undefined, onSuccess: async (result: Payload) => { + clearPersistDataAfterSubmit && store.clearLocalPersistData(); // result为提交接口返回的内容 const dispatcher = await dispatchEvent( 'submitSucc', @@ -1245,6 +1248,7 @@ export default class Form extends React.Component { }); }); } else { + clearPersistDataAfterSubmit && store.clearLocalPersistData(); // type为submit,但是没有配api以及target时,只派发事件 dispatchEvent('submitSucc', createObject(this.props.data, values)); }