限制选择7天的日期范围,限制30天的日期和大于今天的日期

<el-form-item label="日期" prop="date">
    <el-date-picker v-model="form.date" type="daterange" range-separator="至" 
        start-placeholder="开始日期" end-placeholder="结束日期"
        value-format="yyyy-MM-dd" @change="timeChange"
        :picker-options="pickerOptions">
</el-date-picker>
 disabledDate(time) {
     if(vue.pickerMinDate != ''){
         // 最多只能选择7天日期范围
         const day7 = (7-1) * 24 * 3600 * 1000
         let maxTime = vue.pickerMinDate + day7
         if(maxTime > new Date()){
             maxTime = new Date()
         }
         return time.getTime() > maxTime
     }
     const start = new Date(new Date(new Date().toLocaleDateString()).getTime())
     var flag1 = time.getTime() < (start.getTime() - 3600 * 1000 * 24 * (30))//30天前的日期
     return  flag1 || time.getTime() > Date.now();
 }

 

Logo

前往低代码交流专区

更多推荐