getCalendarData(year, month) {
this.date = [];
let firstDayOfMonth =new Date(year, month-1, 1);//本月第一天
let preMonthDay = firstDayOfMonth.getDay() ===0 ?6 : firstDayOfMonth.getDay() -1;//本月第一天星期几 0.星期一 1.星期二
//获取上月的最后一天(上月总共的天数)
let lastDateOfLastMonth =new Date(year, month-1, 0).getDate();
//获取本月最后一天(本月总共的天数)
let lastDateOfMonth =new Date(year, month, 0).getDate();
for (let i =0; i <42; i++) {
let date = i +1 - preMonthDay;
let y = year,
m = month;
if (date <=0) {
m -=1;
date = date + lastDateOfLastMonth;
}else if (date > lastDateOfMonth) {
m +=1;
date = date - lastDateOfMonth;
}
if (m ===13) {
m =1 , y +=1
}
if (m ===0) {
m =12 , y -=1
}
this.date.push({year: y, month: m, ym: y +'-' + m +'-' + date, value: m == month})
}
}