react----DateRangePicker控件使用

react----DateRangePicker控件使用

先上效果图

在这里插入图片描述
1.组件传入如下参数

          <DateRangePicker
            small
            startDatePlaceholderText="开始日期" //未选时间的中文提示
            endDatePlaceholderText="结束日期"
            monthFormat="YYYY[年]MMMM" //时间选择框的标题格式
            startDate={date.startDate}
            startDateId="startDate"
            endDate={date.endDate}
            endDateId="endDate"
            onDatesChange={value => setDate(value)}
            focusedInput={focused}
            onFocusChange={focusedInput => setFocused(focusedInput)}
            orientation="horizontal"
            openDirection="down"
            isOutsideRange={(day) => { //可选日期为今天之前,不设则默认为从今天开始往后
              return !isBeforeDay(day, moment());
            }}
          >

2.时间格式 使用中文表现格式 需要进行如下设置


import moment from "moment";
import 'moment/locale/zh-cn'

  useEffect(()=>{
    //初始化 Moment.js 中的地域信息,日期选择等控件需要使用
    moment.locale(['zh-cn'])
    //console.log(TAG,"useEffect moment:",moment.locales()," moment.locale:",moment.locale())
  },[])

3.DateRangePicker
源码链接
Demo链接

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值