繁体   English   中英

TypeError: date.clone is not a function After added the "name" property to Form.Item (ant design)

[英]TypeError: date.clone is not a function After Added the "name" property to Form.Item (ant design)

我目前正在使用 Ant Design 的 DatePicker 构建应用程序,并且正在使用 Form.item 进行包装。

      <Form.Item
        name={key}
        label={label}
      >
        <DatePicker
          disabledDate={(current) => disableDaysAfterToday(current)}
          onChange={(current) => handleChangeDate(current)}
        />
      </Form.Item>

但是,当“名称”属性添加到 Form.Item 组件时,我最终会收到以下错误:TypeError: date.clone is not a function。 而且,如果我删除此属性或更改为其他字符串,即从 Form.Item 中删除“名称”,一切正常。 有谁能够帮我?

“name”属性用于在<Form/>组件中提供的“initialValues”中选择正确的属性。 如果您不通知它,它不会因为未选择属性而中断,您的输入必须为空。

对我来说,当我在将有问题的属性传递给“initialValues”之前对其进行处理时,它就起作用了。

this.object.date = moment(this.object.date);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM