1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > antd 日期时间选择_react+antd系列之日期选择框DatePicker

antd 日期时间选择_react+antd系列之日期选择框DatePicker

时间:2021-03-16 09:46:16

相关推荐

antd 日期时间选择_react+antd系列之日期选择框DatePicker

1.默认时间

defaultValue={moment('0203')}

format={dateFormat}

/>

默认当前时间:

const dateFormat = 'YYYY-MM-DD';

defaultValue={moment()}

format={dateFormat}

/>

moment()不带参数表示默认当前日期

注意:

1. 获取时间戳

moment().valueOf()

2. 获取格式时间

moment().format('YYYY-MM-DD')

DatePicker组件获取的时间都是moment格式的,要转换一般用这两种

2.不可选择的日期

(1)只能选择今天跟今天之后的日期:

const disabledDate = (current) => {

return current < moment().startOf('day');

}

(2)只能选择今天之前的日期(不包括今天):

const disabledDate = (current) => {

return current > moment().startOf('day');

}

3.禁用日期框

4.日期区间范围选择

5.月份选择

6.选择周

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。