element 时间控件,选择时间范围
作者:互联网
需求,根据不同的用户,可查询的时间段范围不一样
<el-date-picker v-model="queryForm.endTime" size="small" type="datetime" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择结束时间" :picker-options=" probationPeriod == 1 ? pickerOptionsThreeM : probationPeriod == 2 ? pickerOptionsSixM : pickerOptionsOneY " >
:picker-options中使用三元表达式 probationPeriod 为当时时间往前推三个月,2是六个月,3是一年pickerOptionsThreeM: { disabledDate(time) { const threeMonth = new Date().setMonth(new Date().getMonth() - 3); return ( time.getTime() > new Date().getTime() || time.getTime() < threeMonth ); }, }, pickerOptionsSixM: { disabledDate(time) { const threeMonth = new Date().setMonth(new Date().getMonth() - 6); return ( time.getTime() > new Date().getTime() || time.getTime() < threeMonth ); }, }, pickerOptionsOneY: { disabledDate(time) { const threeMonth = new Date().setFullYear( new Date().getFullYear() - 1 ); return ( time.getTime() > new Date().getTime() || time.getTime() < threeMonth ); }, },
标签:控件,const,getTime,element,threeMonth,时间,time,Date,new 来源: https://www.cnblogs.com/guohanting/p/16416990.html