前端
<el-date-picker
v-model="updateval"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
:picker-options="UpadtePo"
value-format="yyyy-MM-dd">
</el-date-picker>
js代码
export default {
data() {
return {
UpadtePo: {
onPick: ({ maxDate, minDate }) => {
this.choiceDate = minDate.getTime();
if (maxDate) {
this.choiceDate = "";
}
},
disabledDate: time => {
if (this.choiceDate!='') {
const one = 30 * 24 * 3600 * 1000;
const minTime = this.choiceDate - one;
const maxTime = this.choiceDate + one;
return time.getTime() < minTime || time.getTime() > maxTime;
}
}
}
};
}
参考:https://blog.csdn.net/carmen_shao/article/details/83622134