Commit 9a21b8b6a4a33d69c4e1b439fc01c4038c150ff9
Committed by
GitHub
1 parent
663d13a6
fix(form): Improve form error handling
* 自定义组件 Array 的元素可能为 null * 自定义组件时没有抛出错误
Showing
2 changed files
with
4 additions
and
2 deletions
src/components/Form/src/hooks/useFormEvents.ts
... | ... | @@ -212,7 +212,9 @@ export function useFormEvents({ |
212 | 212 | const values = await validate(); |
213 | 213 | const res = handleFormValues(values); |
214 | 214 | emit('submit', res); |
215 | - } catch (error) {} | |
215 | + } catch (error) { | |
216 | + throw new Error(error); | |
217 | + } | |
216 | 218 | } |
217 | 219 | |
218 | 220 | return { | ... | ... |
src/components/Form/src/hooks/useFormValues.ts
... | ... | @@ -35,7 +35,7 @@ export function useFormValues({ |
35 | 35 | if (isObject(value)) { |
36 | 36 | value = transformDateFunc(value); |
37 | 37 | } |
38 | - if (isArray(value) && value[0]._isAMomentObject && value[1]._isAMomentObject) { | |
38 | + if (isArray(value) && value[0]?._isAMomentObject && value[1]?._isAMomentObject) { | |
39 | 39 | value = value.map((item) => transformDateFunc(item)); |
40 | 40 | } |
41 | 41 | // Remove spaces | ... | ... |