Browse Source

fix: 修复updateSchema之后会把已填值重置为defaultValue的问题 (#1792)

Henry Rao 3 năm trước cách đây
mục cha
commit
b41e3939ac
1 tập tin đã thay đổi với 4 bổ sung1 xóa
  1. 4 1
      src/components/Form/src/hooks/useFormValues.ts

+ 4 - 1
src/components/Form/src/hooks/useFormValues.ts

@@ -118,7 +118,10 @@ export function useFormValues({
       const { defaultValue } = item;
       if (!isNullOrUnDef(defaultValue)) {
         obj[item.field] = defaultValue;
-        formModel[item.field] = defaultValue;
+
+        if (formModel[item.field] === undefined) {
+          formModel[item.field] = defaultValue;
+        }
       }
     });
     defaultValueRef.value = obj;