vue:element.ui中中日期时间范围选择控件怎么设置选择的范围,不能跨月选择

2020-05-11 社会 216阅读
配置规则:
pickerOptions: {
onPick: ({ maxDate, minDate }) => {
this.choiceDate = minDate.getTime()
if (maxDate) {
this.choiceDate = ''
}
},
disabledDate: (time) => {
const self = this;
if (!!self.choiceDate) {
const startDay = (new Date(self.choiceDate).getDate() - 1) * 24 * 3600 * 1000;
const endDay = (new Date(
new Date(self.choiceDate).getFullYear(),
new Date(self.choiceDate).getMonth() + 1,
0
).getDate() - new Date(self.choiceDate).getDate()) * 24 * 3600 * 1000;
let minTime = self.choiceDate - startDay;
let maxTime = self.choiceDate + endDay;
return time.getTime() < minTime || time.getTime() > maxTime
}
}
},
choiceDate: ''
========================================================
template里面
:picker-options="pickerOptions"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
type="daterange"
align="right"></el-date-picker>
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com