我在 for 循环中的条件语句中收到错误作为意外标记。
我无法弄清楚第 46 行(即 for 循环for (var d = 1; d<=daysInWeek; d++)
)中的预期字符和意外字符有什么问题。
let numberOfDays = this.state.dateClicked.daysInMonth()
var dayArray = []
const daysInWeek = 7;
let weeks = parseInt(numberOfDays/7)
for (var w = 1; w <= weeks; w++) {
dayArray.push(<div className="row justify-content-center">)
var dayNumber;
for (var d = 1; d<=daysInWeek; d++) {
dayNumber = (w-1)*(daysInWeek) + d
dayArray.push(<div className="col-md-1" style={style.cell} key={dayNumber} onClick={this.captureDay.bind(this,{dayNumber})}>{dayNumber}</div>)
}
dayArray.push(</div>)
}
let remdays = this.state.dateClicked.daysInMonth()%7
if (remdays>= 0) {
dayArray.push(<div className="row justify-content-center">)
}
for (let r = 1; r <= remdays; r++){
var dayN = 28+r
<div className="col-md-1" style={style.cell} key={r} onClick={this.captureDay.bind(this,{dayN})}>{dayN}</div>
}
dayArray.push(</div>)
return dayArray;
}```
I am getting error as " Line 46: Parsing error: Unexpected token"
(Line 46 is the for loop)
```for (var d = 1; d<=daysInWeek; d++)```