Skip to content

Commit

Permalink
chore(form): 处理类型问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zyprepare committed Sep 24, 2024
1 parent fe6479a commit 82678d9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/ui/form/src/use-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ export const useForm = <Values = Record<string, any>>({
return fieldValidation.validate(value).catch((error) => {
if (scrollToFirstError && !firstError) {
firstError = true
scrollToNode(fieldName, scrollToFirstError)
scrollToNode(
fieldName,
typeof scrollToFirstError === 'object' ? scrollToFirstError : {}
)
}

// 第一个出错,即退出校验
Expand Down Expand Up @@ -655,7 +658,7 @@ export interface UseFormProps<T = Record<string, any>> {
/**
* 提交失败自动滚动到第一个错误字段
*/
scrollToFirstError?: boolean | Options
scrollToFirstError?: boolean | ScrollOptions
}

export type UseFormReturn = ReturnType<typeof useForm>
Expand Down

0 comments on commit 82678d9

Please sign in to comment.