JS实现:输入某一天日期,获取该日所在周的所有日期
initShowMeetDay(day){ this.thisWeekDay = this.getWeekDays(day) }, getWeekDays(input_day){ let oneDayTime = 1000 * 60 * 60 * 24 let today = new Date(input_day) // 若那一天是周末时,则强制赋值为7 let todayDay = today.getDay() || 7 let startDate = new Date( today.getTime() - oneDayTime * (todayDay - 1) ) let dateList = new Array() for(let i = 0; i < 7; i++){ let temp = new Date(startDate.getTime() + i * oneDayTime) let year = temp.getFullYear() let month = temp.getMonth() + 1 let day = temp.getDate() // dateList[i] = `${year}-${month}-${day}` dateList[i] = `${day}` } return dateList; }