我有 Json 数据
var schedule = [
{ date: "Monday, 9:00am", team1: "Chasing", team1Score: "13", team2: "Amsterdam Money Gang", team2Score: "9"},
{ date: "Monday, 9:00am", team1: "Boomsquad", team1Score: "15", team2: "Beast Amsterdam", team2Score: "11"},
];
现在我需要只使用 javaScript 将它添加到下表中(所以没有 Jquery,但我们可以使用微库)
<tr>
<td data-bind="date"></td>
<td data-bind="team1"></td>
<td data-bind="team1score"></td>
<td data-bind="team2"></td>
<td data-bind="team2score"></td>
</tr>
我正在使用以下内容循环遍历数组,只是现在我不知道如何在每个数组行上创建一个新的 tr
var len = schedule.length;
for (var i=0; i < len; i++) {
}
所以我试图获得以下输出
<tr>
<td>Monday, 9:00am</td>
<td class="winner">Chasing</td>
<td>13 - 9</td>
<td>Amsterdam Money Gang</td>
</tr>
<tr>
<td>Monday, 9:00am</td>
<td class="winner">Boomsquad</td>
<td>15 - 11</td>
<td>Beast Amsterdam</td>
</tr>