element-ui选择时间范围限制条件
选择时间组件:
<el-date-picker v-model.trim="ruleForm.messTime" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions" > </el-date-picker>
限制时间的范围:8.64e7 ( 86400000ms = 1000*24*60*60 )
data() { return { pickerOptions: { disabledDate(time) { //return time.getTime() < Date.now() - 8.64e7;//设置选择今天以及今天之后的日 //return time.getTime() > Date.now(); //设置选择今天以及今天以前的日期 //return time.getTime() < Date.now();//设置选择今天之后的日期(不能选择当天时间) return time.getTime() > Date.now() - 8.64e7 //设置选择今天之前的日期(不能选择当天) // 设置当天23:59:59可选 // let currentTime = this.getNowMonthDay() + ` 23:59:59` // return time.getTime() > new Date(currentTime).getTime() }, }, } }, methods: { getNowMonthDay() { let nowTime = new Date() let year = nowTime.getFullYear() let month = nowTime.getMonth() + 1 let day = nowTime.getDate() return year + "-" + month + "-" + day }, }