代码如下:
let date = new Date()
let year = date.getFullYear()
let month = date.getMonth()
let allDay = new Date(year, month + 1, 0).getDate() //获取当月总天数
let saturday = []; //周六
let sunday = []; //周日
for (let i = 1; i <= allDay; i++) {
let week = new Date(year,month,i).getDay()
let str = `${year}-${(month+1)<10?'0'+(month+1):(month+1)}-${i<10?'0'+i:i}`
if (week === 0){
sunday.push({
"date": str, "disable": true
})
} else if(week === 6){
saturday.push({
"date": str, "disable": true
})
}
}
let time = sunday.concat(saturday);
console.log(time)