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里面
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
type="daterange"
align="right"></el-date-picker>