element时间日期组件要求默认选中最近三个月的日期时间
//data中查询条件设置了承接时间的数组
data(){
return {
queryForm: {
currentPage: 1,
pageSize: 20,
creationDate: [this.preTime(), this.currentTime()],
},
}
}
// 对应的方法中:
preTime(flag) {
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() - 1;
if (month === 0) {
month = 12 + month;
year = year - 1;
}
let day = date.getDate();
if (flag) {
year = year - 1;
month = 12 + month;
}
let timeData = year + '-' + month + '-' + day + ' ';
return new Date(timeData).getTime()
},
currentTime() {
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
let flag = false;
if (month <= 2) {
flag = true;
this.preTime(flag)
}
let timeData = year + '-' + month + '-' + day + ' ' + '23:59:59';
return new Date(timeData).getTime();
},