如何解决antd ver 3.26.19 验证表单时出错
在现有项目中,我使用以下代码片段插入了一个数值输入字段:
<Form.Item>
{this.props.form.getFieldDecorator('username',{
trigger: 'onBlur',validateTrigger: 'onBlur',valuePropName: 'defaultValue',initialValue: 123,rules: [
{ required: true,message: 'Please input your username!' },{ pattern: /^\s*[0-9]+\s*$/,message: 'wrong input!!!' }
],})(
<Input
prefix={<Icon type="user" style={{ color: 'rgba(0,.25)' }} />}
placeholder="Username"
/>,)}
</Form.Item>
输入了值,但验证无效,输出如下信息:
Uncaught TypeError: Cannot convert undefined or null to object
at Function.entries (<anonymous>)
at onFieldsChange (config-section.jsx?fa36:956)
at HotComponent.setFields (createBaseForm.js?c32b:327)
at HotComponent.validateFieldsInternal (createBaseForm.js?c32b:455)
at HotComponent.onCollectValidate (createBaseForm.js?c32b:191)
at HTMLUnknownElement.callCallback (react-dom.development.js?61bb:188)
at Object.invokeGuardedCallbackDev (react-dom.development.js?61bb:237)
at invokeGuardedCallback (react-dom.development.js?61bb:292)
at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js?61bb:306)
at executeDispatch (react-dom.development.js?61bb:389)
请写下如何修复错误并解决问题
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。