1 getWeekFn() { 2 let weekDay = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]; 3 let new_Date = new Date() 4 let timesStamp = new_Date.getTime(); 5 let currenDay = new_Date.getDay(); 6 let dates = []; 7 for(let i = 0; i < 7; i++) { 8 let myDate = new Date(Date.parse(new Date(timesStamp + 24 * 60 * 60 * 1000 * (i - (currenDay + 6) % 7)).toLocaleDateString().replace(/[年月]/g, '-').replace(/[日上下午]/g, ''))); 9 dates.push({ 10 value: new Date(timesStamp + 24 * 60 * 60 * 1000 * (i - (currenDay + 6) % 7)).toLocaleDateString().replace(/[年月]/g, '-').replace(/[日上下午]/g, ''), 11 label: new Date(timesStamp + 24 * 60 * 60 * 1000 * (i - (currenDay + 6) % 7)).toLocaleDateString().replace(/[年月]/g, '-').replace(/[日上下午]/g, '') + weekDay[myDate.getDay()], 12 } 13 ); 14 } 15 return dates 16 }, 17 18 console.log(getWeekFn())