In vue:element.ui, how the date-time range selection control sets the range of the selection, the start time and end time are the same month. No cross-month choice?

topic description

if the start time is January, then the end time can only be selected within January.

sources of topics and their own ideas

related codes

/ / Please paste the code text below (please do not replace the code with pictures)
< el-date-picker VMI model = "pickerValue" type= "datetimerange" align= "left" range-separator= "to"

      start-placeholder="" end-placeholder="" :picker-options="pickerOptions" @change="handleChange">
    </el-date-picker>

what result do you expect? What is the error message actually seen?

Jul.11,2022

add a selectedDate to the data to save the selected object

then do the following processing in pickerOptions

pickerOptions:{
    disabledDate(date1){
        // selectedDate 
        return !(this.selectedDate && this.selectedDate.getMonth()!==date1.getMonth())
    },
    onPick(date){
        // selectedDate selectedDate 
        if(date.minDate && !date.maxDate){
            this.selectedDate = date.minDate
        }else{
            this.selectedDate = null
        }
    }
}

provides an idea that the code has not tried


Hello, have you made this restriction that you can't choose across months? I also encounter this problem now, please learn from it!

Menu