fix(form): Improve form error handling

* 自定义组件 Array 的元素可能为 null

* 自定义组件时没有抛出错误
This commit is contained in:
Liu Ya 2021-04-12 20:50:45 +08:00 committed by GitHub
parent 663d13a67f
commit 9a21b8b6a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -212,7 +212,9 @@ export function useFormEvents({
const values = await validate();
const res = handleFormValues(values);
emit('submit', res);
} catch (error) {}
} catch (error) {
throw new Error(error);
}
}
return {

View File

@ -35,7 +35,7 @@ export function useFormValues({
if (isObject(value)) {
value = transformDateFunc(value);
}
if (isArray(value) && value[0]._isAMomentObject && value[1]._isAMomentObject) {
if (isArray(value) && value[0]?._isAMomentObject && value[1]?._isAMomentObject) {
value = value.map((item) => transformDateFunc(item));
}
// Remove spaces