// 时间切换
private tabTime(num: number) {
let self = this;
let now = new Date();
let arr = [];
if (num > 0) {
this.num2 ++;
}
if (num < 0) {
this.num2 --;
}
let b = Number(now.getMonth());
now.setMonth(b + Number(this.num2)); // 输出时间
let newA = now.getFullYear();
let newB: any = Number(now.getMonth());
let newC: any = now.getDay();
newB = ((newB + 1) < 10 ? "0" : "") + (newB + 1);
let y = newA + ' - ' + (newB);
this.currMonthData = y;
let days = this.getEveryMonthDays(newA, newB);
this.StartTimeStamp = Number(newA + newB + "01");
this.CurrTimeStamp = Number(newA + newB + days);
this.loadChart(this.StartTimeStamp, this.CurrTimeStamp);
}
淡淡烟草味2017-06-30 09:58:38
If month represents the current month, use new Date(year, month-1) to get the previous/next month, new Date(year, month, 0) to get the last day of the previous month, new Date(year, month, 1) Get the first day of the current month, new Date(year, month+1, 0) gets the last day of the current month (that is, the total number of days in the current month). Then use these values to calculate the number of days in the month after switching and the number of indented days before the first week, and finally render them