// 获取当前日期之后或之前的七天
initData(date){
var myDate = new Date();
// console.log(myDate);
// myDate.setDate(myDate.getDate() - 7); //后7天就把该行代码注释
var dateArray = [];
var dateTemp;
var fullDate;
var flag = 1;
for (var i = 0; i < 7; i++) {
console.log(myDate);
var year = myDate.getFullYear()
var month = myDate.getMonth() + 1;
var date = myDate.getDate();
var week = moment(myDate).format('dddd')
month < 10 ? (month = "0" + month) : month;
date < 10 ? (date = "0" + date) : date;
dateTemp = month + "月" + date + "日";
fullDate = year + "-" + month + "-" + date
dateArray.push({'date': dateTemp,'week':week,'fullDate': fullDate});
// 为渲染号表自定义格式
myDate.setDate(myDate.getDate() + flag);
}
this.dateList = dateArray
console.log(dateArray);
},
//获取当前日期所在周的周一
getMonday(date,n){
var checkDate = date; // 深拷贝 会改变传递过来的值 传递过来的为一个日期类型的值
checkDate.setDate(checkDate.getDate() + n - (checkDate.getDay() || 7));
return checkDate;
},