blog icon indicating copy to clipboard operation
blog copied to clipboard

Antd && Moment

Open yongheng2016 opened this issue 7 years ago • 0 comments

<DatePicker
          placeholder="请选择"
          onChange={onChange}
          defaultValue={moment().subtract(1, 'days')}  // 默认选择日期是今天的前一天
          disabledDate={this.disabledDate}
        // onChange={this.change}
 />

  disabledDate(current) {
    // 选择范围在今天之前(不包括今天)
    return current && !current.isBetween(moment().startOf('year'), moment().subtract(1, 'days'));

   // 选择范围在今天之前(包括今天)
   return current && current >= moment().endOf('day');
  }

yongheng2016 avatar Sep 01 '18 02:09 yongheng2016