效果展示:
开始时间:
结束时间:
<el-form-item label="活动时间" required><el-col :span="11"><el-form-item prop="startDate"><el-date-pickertype="date"placeholder="选择开始日期"v-model="queryParams.startDate"style="width: 100%;":picker-options="startDateOptions"></el-date-picker></el-form-item></el-col><el-col class="line" :span="2">-</el-col><el-col :span="11"><el-form-item prop="endDate"><el-date-pickertype="date"placeholder="选择结束日期"v-model="queryParams.endDate"style="width: 100%;":picker-options="EndDateOptions"></el-date-picker></el-form-item></el-col></el-form-item>
data中定义:
startDateOptions:{disabledDate:(time)=>{return time.getTime() > Date.now() || time.getTime() == Date.now() || time.getTime()< new Date().setFullYear((new Date().getFullYear()-1))}},
EndDateOptions: {disabledDate: (time) => {return time.getTime() < new Date(this.statDate).getTime() || time.getTime() > Date.now() || time.getTime() > Date.now(this.statDate) // 如果当天可选,就不用减8.64e7}},