简体   繁体   English

Antd Datepicker 日期格式

[英]Antd Datepicker date format

I'm receiving data from API and passing it immediatly to <Form> initialValue .我从 API 接收数据并立即将其传递给<Form> initialValue But registerDate is in string format like "01-01-2022" and when <Form.Item> is passing it into <DatePicker> i've got an error:但是registerDate的字符串格式类似于“01-01-2022”,当<Form.Item>将其传递到<DatePicker>时,我遇到了一个错误:

Error: t.clone is not a function [...]

How can I repair it?我该如何修复它? Can I format the date before passing it into <Datepicker> in <Form.Item> ?我可以在将日期传递到<Datepicker> Form.Item> 中的<Form.Item>之前格式化日期吗?

Code example here: https://stackblitz.com/edit/react-cxyphe此处的代码示例: https://stackblitz.com/edit/react-cxyphe

It looks like the name in Form.Item is causing the problem.看起来是 Form.Item 中的名称导致了问题。 If you remove name from line 20 it should render the datePicker.如果您从第 20 行删除名称,它应该呈现 datePicker。 AntD also some examples of using a date picker in a form. AntD还提供了一些在表单中使用日期选择器的示例。

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

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