// 获取年初-年末、月初-月末、
getNowTime() {
var now = new Date();
var year = now.getFullYear(); //得到年份
var month = now.getMonth(); //得到月份
var day = now.getDate(); //得到天
if (day < 10) {
day = "0" + day
}
month = month + 1;
month = month.toString().padStart(2, "0");
var defaultDate = `${year}-${month}`;
this.value1 = defaultDate;
this.value2 = defaultDate;
this.value3 = defaultDate;
this.value4 = defaultDate;
this.value6 = defaultDate;
this.today.date_from = `${year}-${month}-${day}`
this.today.date_to = `${year}-${month}-${day}`
this.month.date_from = `${year}-${month}-01`
this.month.date_to = `${year}-${month}-31`
this.year.date_from = `${year}-01-01`
this.year.date_to = `${year}-12-31`
console.log(this.today.date_from + '-today.date_from')
console.log(this.today.date_to + '-today.date_to')
console.log(this.month.date_from + '-month.date_from')
console.log(this.month.date_to + '-month.date_to')
console.log(this.year.date_from + '-year.date_from')
console.log(this.year.date_to + '-year.date_to')
// 对象不要直接赋值,其中涉及深浅拷贝原理
switch (this.top_value) {
case 1:
this.date = JSON.parse(JSON.stringify(this.today));
break;
case 2:
this.date = JSON.parse(JSON.stringify(this.month));
break;
case 3:
this.date = JSON.parse(JSON.stringify(this.year));
break;
case 4:
this.date.date_from = null;
this.date.date_to = null
break;
default:
break;
}
},
08-04
2148
09-11
3923
07-29
141
02-10
956