<el-date-picker
v-model="times"
:picker-options="pickerOptions"
type="daterange"
range-separator="——"
start-placeholder="起始时间"
end-placeholder="截止时间"
value-format="yyyy-MM-dd">
</el-date-picker>
data() {
return {
times: '',
cuttentTime: '',
pickerOptions: {
onPick: ({ maxDate, minDate }) => {
this.cuttentTime = minDate.getTime()
if (maxDate) {
this.cuttentTime = ''
}
},
disabledDate: (time) => {
if (this.cuttentTime != '') {
const one = 30 * 24 * 3600 * 1000
const minTime = this.cuttentTime - one
const maxTime = this.cuttentTime + one
return time.getTime() < minTime || time.getTime() > maxTime
}
}
}
}
}