antd踩坑:value.locale is not a function
Posted foxcharon
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了antd踩坑:value.locale is not a function相关的知识,希望对你有一定的参考价值。
这个问题来源于日期选择器 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的主要内容,如果未能解决你的问题,请参考以下文章
实力踩坑:There is no getter for property named ‘XXX‘ ‘class XXX‘
实力踩坑:Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedde
vue 踩坑 -- 'qrcode' is assigned a value but never used no-unused-vars
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedd(究极踩坑完美解决)