소스 검색

Update useFormEvents.ts (#514)

fix: 修复 表单回显时,参数为null或者''时, 报Invalid date的错
最后 3 년 전
부모
커밋
e689ee5fa6
1개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 3
      src/components/Form/src/hooks/useFormEvents.ts

+ 3 - 3
src/components/Form/src/hooks/useFormEvents.ts

@@ -67,13 +67,13 @@ export function useFormEvents({
         // time type
         if (itemIsDateType(key)) {
           if (Array.isArray(value)) {
-            const arr: moment.Moment[] = [];
+            const arr: any[] = [];
             for (const ele of value) {
-              arr.push(dateUtil(ele));
+              arr.push(ele ? dateUtil(ele) : null);
             }
             formModel[key] = arr;
           } else {
-            formModel[key] = dateUtil(value);
+            formModel[key] = value ? dateUtil(value) : null;
           }
         } else {
           formModel[key] = value;