当选择日期组件的开始时间以后,动态设置可选范围在一个月内,网上有通过.native来获取每次点击事件,但无法生效,事件只触发一次,选择时间的时候不触发了,有没有其他办法实现?
https://www.lanwuyaojiu.cn/bl...
<DatePicker ref="date" slot="extra"
:value="time"
:options="dateOption"
@click.native="nativeClick"
type="daterange"
placement="bottom-end"
placeholder="选择日期" style="width: 200px"></DatePicker>
nativeClick() {
const target = this.$refs['date'].$refs['pickerPanel']
const { from, to } = target['rangeState']
console.log(from, to)
if (from && ! to) {
this.dateOption = {
disabledDate(value) {
const startTime = new Date(from)
const endTime = new Date(from)
startTime.setDate(from.getDate() - 30)
endTime.setDate(from.getDate() + 30)
return !(value >= startTime && value <= endTime)
}
}
} else {
this.dateOption = {
disabledDate() {
return false
}
}
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…