antd 之TimePicker设置禁用时间
Posted spy66
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了antd 之TimePicker设置禁用时间相关的知识,希望对你有一定的参考价值。
-
startTime: ‘00:00:00‘,
-
endTime: ‘23:59:59‘
getDisabledHours () {
let hours = []
let time = this.startTime
let timeArr = time.split(‘:‘)
for (var i = 0; i < parseInt(timeArr[0]); i++) {
hours.push(i)
}
return hours
},
getDisabledMinutes (selectedHour) {
let time = this.startTime
let timeArr = time.split(‘:‘)
let minutes = []
if (selectedHour == parseInt(timeArr[0])) {
for(var i = 0; i < parseInt(timeArr[1]); i++) {
minutes.push(i)
}
}
return minutes
},
getDisabledSeconds (selectedHour, selectedMinute) {
let time = this.startTime
let timeArr = time.split(‘:‘)
let second = []
if (selectedHour == parseInt(timeArr[0]) && selectedMinute == parseInt(timeArr[1])) {
for(var i = 0; i <= parseInt(timeArr[2]); i++) {
second.push(i)
}
}
return second
}
以上是关于antd 之TimePicker设置禁用时间的主要内容,如果未能解决你的问题,请参考以下文章
AntD React:在 DateRangePicker 中禁用特定日期的时间范围
antd RangePicker/DatePicker 动态满足多个条件禁用
antd RangePicker/DatePicker 动态满足多个条件禁用