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 (将#修改为@)