2019-12-27 16:26:50 +08:00
|
|
|
# Disable Time
|
|
|
|
You can disable some time.
|
|
|
|
|
2019-11-29 15:24:37 +08:00
|
|
|
```html
|
|
|
|
<n-time-picker
|
|
|
|
v-model="time0"
|
2019-12-27 16:26:50 +08:00
|
|
|
:is-hour-disabled="isHourDisabled"
|
|
|
|
:is-minute-disabled="isMinuteDisabled"
|
|
|
|
:is-second-disabled="isSecondDisabled"
|
2019-11-29 15:24:37 +08:00
|
|
|
/>
|
|
|
|
|
|
|
|
```
|
|
|
|
```js
|
|
|
|
export default {
|
|
|
|
data () {
|
|
|
|
return {
|
2019-12-27 16:26:50 +08:00
|
|
|
time0: null
|
2019-11-29 15:24:37 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2019-12-27 16:26:50 +08:00
|
|
|
isHourDisabled (hour) {
|
|
|
|
return hour % 2 === 0
|
2019-11-29 15:24:37 +08:00
|
|
|
},
|
2019-12-27 16:26:50 +08:00
|
|
|
isMinuteDisabled (minute, selectedHour) {
|
|
|
|
if (selectedHour === null) return false
|
|
|
|
if (Number(selectedHour) < 12) {
|
|
|
|
return minute < 30
|
2019-12-04 11:05:05 +08:00
|
|
|
} else {
|
|
|
|
return false
|
2019-11-29 15:24:37 +08:00
|
|
|
}
|
|
|
|
},
|
2019-12-27 16:26:50 +08:00
|
|
|
isSecondDisabled (second, selectedMinute, selectedHour) {
|
|
|
|
if (selectedHour === null || selectedMinute === null) return false
|
|
|
|
if (Number(selectedHour) > 20 && Number(selectedMinute) < 30) {
|
|
|
|
return second < 40
|
2019-12-04 11:05:05 +08:00
|
|
|
} else {
|
|
|
|
return false
|
2019-11-29 15:24:37 +08:00
|
|
|
}
|
2019-12-23 17:20:13 +08:00
|
|
|
},
|
|
|
|
},
|
2019-11-29 15:24:37 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
```css
|
|
|
|
.n-time-picker {
|
|
|
|
margin: 0 12px 8px 0;
|
|
|
|
}
|
|
|
|
```
|