Vue ElementUI el-date-picker设置禁用时间区间
1.el-date-picker设置只能选当天
el-date-picker设置
:picker-options="pickerOptions"
pickerOptions: { onPick: (time) => { //当第一时间选中才设置禁用 if (time.minDate && !time.maxDate) { this.timeOptionRange = time.minDate; } if (time.maxDate) { this.timeOptionRange = null; } }, disabledDate: (time) => { let timeOptionRange = this.timeOptionRange; let secondNum = 60 * 60 * 24 * 1 * 1000 - 1; if (timeOptionRange) { if (timeOptionRange.getTime() + secondNum > Date.now() - 8.64e6) { return ( time.getTime() > Date.now() - 8.64e6 || time.getTime() < timeOptionRange.getTime() - secondNum ); } return ( time.getTime() > timeOptionRange.getTime() + secondNum || time.getTime() < timeOptionRange.getTime() - secondNum ); } }, },