element给的控件其实大多数是不满足需求的,所以有时候需要自己去修改,网上找找就很多方法,但不会写的同志们就犯愁了,也得找到适合自己需求的不是,话不多说,上干货
html:
1 2 3 4 5 6 7 8 9 10 | v-model="week" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" size="small" value-format="yyyy-MM-dd" :picker-options="pickerOptions" :clearable="false" ></el-date-picker> |
html里面很假单,就添加了一个属性 :picker-options=“pickerOptions”
data数据里面:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | data(){ return{ pickerOptions: { disabledDate(time) { let curDate = new Date().getTime(); let three = 180 * 24 * 3600 * 1000; let threeMonths = curDate - three; var thatDay = time.getTime(); return ( time.getTime() > Date.now() - 8.64e6 || time.getTime() < threeMonths ); } } } } |
这样就可以了,只能选择当天之前180天的日期