form data 可以通过 __pristine 获取原始值

This commit is contained in:
liaoxuezhi 2019-09-10 12:35:33 +08:00
parent c0de429521
commit 77e2158540
1 changed files with 11 additions and 1 deletions

View File

@ -122,7 +122,6 @@ export const FormStore = ServiceStore.named('FormStore')
} }
setVariable(data, name, value); setVariable(data, name, value);
self.data = data;
if (isPristine) { if (isPristine) {
const pristine = cloneObject(self.pristine); const pristine = cloneObject(self.pristine);
@ -130,6 +129,17 @@ export const FormStore = ServiceStore.named('FormStore')
self.pristine = pristine; 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) { if (self.persistData) {
setPersistData(); setPersistData();
} }