首页 > 其他 > 详细

antd踩坑:value.locale is not a function

时间:2020-02-02 14:58:24      阅读:1323      评论:0      收藏:0      [点我收藏+]

这个问题来源于日期选择器 RangerPicker 的特殊情况。

                            <Col span={7} key={9}>
                                <FormItem label="投运时间" {...formItemLayout2}>
                                    {getFieldDecorator(‘tysj‘, {
                                        initialValue: [undefined, moment().endOf(‘month‘)],
                                        rules: [
                                            {
                                                required: false,
                                                message: ‘投运时间!‘,
                                            },
                                        ],
                                    })(<RangerPicker style={{ width:‘100%‘}} format="YYYY-MM-DD" allowClear={true} />)}
                                </FormItem>
                            </Col>

有时我们希望默认值一边有范围,一边没有范围。

比如 几月几号之前。

那么在表单赋值的时候,原先写的是:

initialValue: [‘‘, moment().endOf(‘month‘)],

但是这样会导致清除时报错:

value.locale is not a function

而只要改成:

initialValue: [undefined, moment().endOf(‘month‘)],

就可以了。

 

antd踩坑:value.locale is not a function

原文:https://www.cnblogs.com/foxcharon/p/12252147.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!