From 77e215854094b1dc625ffc02a69260f5bd213747 Mon Sep 17 00:00:00 2001 From: liaoxuezhi Date: Tue, 10 Sep 2019 12:35:33 +0800 Subject: [PATCH] =?UTF-8?q?form=20data=20=E5=8F=AF=E4=BB=A5=E9=80=9A?= =?UTF-8?q?=E8=BF=87=20=5F=5Fpristine=20=E8=8E=B7=E5=8F=96=E5=8E=9F?= =?UTF-8?q?=E5=A7=8B=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/form.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/store/form.ts b/src/store/form.ts index 2d45b330..3328914f 100644 --- a/src/store/form.ts +++ b/src/store/form.ts @@ -122,13 +122,23 @@ export const FormStore = ServiceStore.named('FormStore') } setVariable(data, name, value); - self.data = data; if (isPristine) { const pristine = cloneObject(self.pristine); setVariable(pristine, name, value); self.pristine = pristine; } + + if (!data.__pristine) { + Object.defineProperty(data, '__pristine', { + value: self.pristine, + enumerable: false, + configurable: false, + writable: false + }); + } + + self.data = data; if (self.persistData) { setPersistData();