zoukankan      html  css  js  c++  java
  • antd- DatePicker中-禁用时间

    antd-的DatePicker是很好使用的一个时间组件,但是需要根据需求的变化进行一些改变,

    例如禁用时间,国际化等。

    1、禁用时间:DatePicker中-禁用时间

    handleData(time){
        if(!time){
    	return false
        }else{
    	// 大于当前日期不能选 time > moment()
    	// 小于当前日期不能选 time < moment().subtract(1, "days")
    	// 只能选前7后7 time < moment().subtract(7, "days") || time > moment().add(7, 'd')
    	return time < moment().subtract(7, "days") || time > moment().add(7, 'd')
        }
    }
     
    
    <RangePicker  disabledDate={this.handleData}/>
    

    2、直接使用antd的DatePicker是英文,这样很不友好,可以改为中文。

    antd中有国际化的案例,但是使用中却出现了很多报错的问题,可以用这种方法使用

    import locale from 'antd/lib/date-picker/locale/zh_CN';
    import 'moment/locale/zh-cn';
  • 相关阅读:
    164-268. 丢失的数字
    163-20. 有效的括号
    Sword 30
    Sword 29
    Sword 27
    Sword 25
    Sword 24
    Sword 22
    Sword 21
    Sword 18
  • 原文地址:https://www.cnblogs.com/liumcb/p/13043556.html
Copyright © 2011-2022 走看看