After selecting a date with el-date-picker, the three months before and after cannot be selected and will be grayed out.

el-date-picker selects the date control. After selecting a date, the dates before the first three months cannot be selected, and the dates in the next three months cannot be selected, and become grayed out.

The current date selected is April 12th, and then the dates three months ago cannot be selected, and then the dates three months afterward cannot be selected. The effect is as shown in the figure below:

 

 

<el-form-item label="操作时间">
    <el-date-picker
       v-model="dateValue"
       type="daterange"
       range-separator="至"
       style="width:100%;max-width:100%"
       start-placeholder="开始日期"
       end-placeholder="结束日期"
       value-format="yyyy-MM-dd"
       :clearable="false"
       :picker-options="pickerOptions">
    </el-date-picker>
</el-form-item>
 pickerOptions:{
     disabledDate(time) {
         let curDate = new Date().getTime()
         let three = 90 * 24 * 3600 * 1000
         let minTime = curDate - three
         let maxTime = curDate + three
         return time.getTime() > maxTime || time.getTime() < minTime
     },
                  
},

Three is the time. If the time changes, you can modify this field.

Guess you like

Origin blog.csdn.net/weixin_50999303/article/details/130105539