element 时间选择器时间跨度设置 2天

it2025-01-30  19

直接上代码叭

<el-date-picker v-model="dateParam" type="datetimerange" :picker-options="pickerOptions" > </el-date-picker> export default { data() { return { timeOptionRange: '', pickerOptions: { // 时间跨度限制为2天 onPick: time => { if (time.minDate && !time.maxDate) { this.timeOptionRange = time.minDate; } if (time.maxDate) { this.timeOptionRange = null; } }, disabledDate: time => { const timeOptionRange = this.timeOptionRange; const secondNum = 60 * 60 * 24 * 1 * 1000; if (timeOptionRange) { return (time.getTime() > timeOptionRange.getTime() + secondNum || time.getTime() < timeOptionRange.getTime() - secondNum); } return false; } } } } }

 

最新回复(0)