简体   繁体   中英

How to disable ant design time picker paste time

Im using ant design time picker for my react application, i have some conflict on the time pricker, i want to know how to disable past time before the today current time.

This is my code

   getDisabledTime = () => {

        var hours = [];
        for(var i =0; i < moment().hour(); i++){
            hours.push(i);
        }
        return hours;

    }


 <TimePicker onChange={onChange} disabledTimes={this.getDisabledTimes()}/>

The prop name is disabledHours and it is a function.

function getDisabledHours() {
  var hours = [];
  for (let i = 0; i < moment().hour(); i++) {
    hours.push(i);
  }
  return hours;
}


<TimePicker disabledHours={getDisabledHours} />

Working codesandbox .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM