1.1.3
antd-mobile 1.1.3,react 15.5.4 ,rc-form 1.3.1
https://codepen.io/chengky/pen/rmrBBV
1.DatePicker组件不设置format,点击“设置日期”按扭(使用了rc-form的setFieldsValue赋值),此时报错:
date-picker/utils.tsx 24行,Uncaught TypeError: t.format is not a function
2.按照提示给DatePicker组件设置format,此时再点击“设置日期”按扭赋值正确,但点击日历组件时报错:
rmc-date-picker/lib/DatePicker.tsx 171行,Uncaught TypeError: a.year is not a function
rc-form的setFieldsValue赋值后,日历使用正常
Uncaught TypeError: a.year is not a function
at Object.getDateData (DatePicker.js:171)
at Object.getValueCols (DatePicker.js:349)
at Object.render (DatePicker.js:362)
at p._renderValidatedComponentWithoutOwnerOrContext (react-dom.min.js:13)
at p._renderValidatedComponent (react-dom.min.js:13)
at performInitialMount (react-dom.min.js:13)
at p.mountComponent (react-dom.min.js:13)
at Object.mountComponent (react-dom.min.js:14)
at h.mountChildren (react-dom.min.js:14)
at h._createInitialChildren (react-dom.min.js:13)
It will be better to write your issue/comment in English, so more people can understand you.
And this means that more people can help you or benefit from your issue/comment.
See: https://github.com/ant-design/ant-design/issues/4897
DatePicker 的 value 是个 moment 对象,不能传 string.
@yesmeck 谢谢。原来moment().format()后变成了字符串
DatePicker上的 format只是显示用?
那使用时,一般获取数据源初始值为字符串,则在使用rc-form的initialValue时需要转换为moment对象
然后保存时又需要转换为字符串
当前应用场景就是大json构造多个日期的复杂表单,每次都要单独把日期进行转换,感觉不合理。
建议value可以为string,并在DatePicker组件上增加转换方法可以string转为moment对像
真是个好组件啊,真好用😅😅
antd mobile 2.0 会去掉 momemt.js
Most helpful comment
DatePicker上的 format只是显示用?
那使用时,一般获取数据源初始值为字符串,则在使用rc-form的initialValue时需要转换为moment对象
然后保存时又需要转换为字符串
当前应用场景就是大json构造多个日期的复杂表单,每次都要单独把日期进行转换,感觉不合理。
建议value可以为string,并在DatePicker组件上增加转换方法可以string转为moment对像