let weekList = [
{id: 1, name: '星期一', date: ''},
{id: 2, name: '星期二', date: ''},
{id: 3, name: '星期三', date: ''},
{id: 4, name: '星期四', date: ''},
{id: 5, name: '星期五', date: ''},
{id: 6, name: '星期六', date: ''},
{id: 7, name: '星期日', date: ''},
];
let nowDate = moment(new Date().getTime()).format('YYYY-MM-DD'); // 获取当前日期
let j = 0; // 循环7次
for(let i = (7 - new Date().getDay()); j < 7 ; i--) {
// 获取当前日期时间戳 //获取当前日期距离当前项的星期有多少天
this.weekList[j].date = moment(new Date(nowDate).getTime() + (24* 60*60*1000 * (7 - new Date().getDay() - i))).format('YYYY-MM-DD')
j ++;
}
标签:name,Date,日期,let,date,new,周一,id,周日
From: https://www.cnblogs.com/shymi/p/16594332.html