我正在尝试为某些任务创建每周一周的时间表,最终,我希望能够通过一些箭头导航/分页几周。
这里我打印了从当月到阵列的日期,我想将它们呈现在表格单元格中,以便它们形成某种日历(从星期一到星期日,后来很有可能动态分页几周)......也许是任何建议?
var getDaysArray = function(year, month) {
var names = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
var date = new Date(year, month - 1, 1);
var result = [];
while (date.getMonth() == month - 1) {
result.push(date.getDate() + "-" + names[date.getDay()]);
date.setDate(date.getDate() + 1);
}
console.log(result);
}
getDaysArray(2017, 10);
<table>
<tr>
<th>Name:</th>
<th>Mon</th>
<th>Tue</th>
<th>Wed</th>
<th>Thu</th>
<th>Fri</th>
<th>Sat</th>
<th>Sun</th>
</tr>
<tr>
<td>First week</td>
<td>Mon (1st...)</td>
<td>Tue (2nd...)</td>
<td>Wed</td>
<td>Thu</td>
<td>Fri</td>
<td>Sat</td>
<td>Sun</td>
</tr>
<tr>
<td>Second week</td>
<td>Mon</td>
<td>Tue</td>
<td>Wed</td>
<td>Thu</td>
<td>Fri</td>
<td>Sat</td>
<td>Sun</td>
</tr>
</table>
<!-- /table -->