[form]表单组件是否可以提供一个自定义错误设置功能 #13922
fangjc1986
started this conversation in
Ideas
Replies: 3 comments 6 replies
-
不是有自定义表单校验吗?demo 里面就是用 setTimeout 模拟了异步请求。 |
Beta Was this translation helpful? Give feedback.
5 replies
-
这个功能好,苦等这个功能许久了😄 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
需求来源
username
前端检查字符串格式,但是提交的时候可能存在username
重复的现象;username
重复的时候, 后端会返回类似这样的验证错误信息:{ username : "此用户名已存在" }
;username
输入框的下方以提示用户;当前处理方案
validator
的异步校验方式进行校验,但是这样就需要后端提供一个额外的接口专门做校验,且在提交表单的时候的校验错误无法传递到表单上;其他框架已有的处理方案
arco-design
在form
组件上提供了setFields
的额外功能,用于设置某个字段的当前状态,从而可以将服务器返回的错误信息手动添加到form
表单上;结论与需求
element-plus
也可以提供类似的setFields
的方法来手动设置表单状态;实现代码示例
Beta Was this translation helpful? Give feedback.
All reactions