pickerOptionsStart:{ disabledDate:(time)=> { // 获取当前日期并减少30天 // console.log(time,'..........tiem'); // console.log(time,'..........tiem'); if (this.endDate!='') { // console.log(this.endDate,'..........this.endDate'); const currentDate =new Date(this.endDate); // console.log(currentDate,'..........currentDate'); currentDate.setDate(currentDate.getDate() - 30); // 比较当前日期与要比较的日期是否不在范围内 return time.getTime() < currentDate.getTime() || time.getTime() > currentDate.getTime() + 30 * 24 * 60 * 60 * 1000; } }, }, pickerOptionsEnd:{ disabledDate:(time)=> { // 获取当前日期并减少30天 if (this.startDate!='') { const currentDate = new Date(this.startDate); currentDate.setDate(currentDate.getDate() + 30); // 比较当前日期与要比较的日期是否不在范围内 return time.getTime() > currentDate.getTime() || time.getTime() < currentDate.getTime() - 30 * 24 * 60 * 60 * 1000; } }, }
:picker-options="pickerOptionsStart" :picker-options="pickerOptionsEnd"
<date-picker v-model="startDate" :dateWidth="200" @dateChange="onStartDate($event)" :picker-options="pickerOptionsStart" ></date-picker> </el-form-item> </el-col> <el-col class="line" :span="1">至</el-col> <el-col :span="7"> <el-form-item prop="endDate"> <date-picker v-model="endDate" :dateWidth="200" @dateChange="onEndDate($event)" :picker-options="pickerOptionsEnd" ></date-picker>
标签:picker,endDate,option,getTime,30,time,currentDate From: https://www.cnblogs.com/xiaobaizitaibai/p/17730359.html