Skip to content

fix: Form validateClear 传入指定字段名时增加可选链容错处理 - #2218

Merged
saint3347 merged 2 commits into
masterfrom
fix/form-validateClear-optional-chaining
May 28, 2026
Merged

saint3347 merged 2 commits into
masterfrom
fix/form-validateClear-optional-chaining

Conversation

@saint3347

Copy link
Copy Markdown
Contributor

问题描述

validateClear 方法在后续版本中新增了 names 参数,允许用户清除指定字段的校验状态。但当传入的字段名在 $validator 中不存在时(如字段未挂载、已卸载或拼写错误),会抛出 TypeError: this.$validator[k] is not a function

修复方案

在调用 validator 函数时使用可选链 ?.,当 validator 不存在时安全返回 undefined 而非报错。

改动文件

  • src/Datum/Form.ts — 增加 ?. 容错
  • site/pages/documentation/changelog/2.x.x.md — 添加 2.0.33 changelog

@saint3347
saint3347 merged commit a479aac into master May 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant