如果没有无容器控制流语法并且具有有效的html,是否可以在下面呈现相同的内容?
<tbody data-bind="foreach: dates">
<tr>
<td class="empty"></td>
<td class="date-container" data-bind="attr: { colspan: $parent.gymCourts().length }">
<div class="date" data-bind="html: date"></div>
</td>
</tr>
<!-- ko foreach: times -->
<tr class="time-games">
<td class="time-container">
<div class="time" data-bind="html: time"></div>
</td>
<!-- ko foreach: games -->
<td class="game-container">
<div class="game">
<span data-bind="html: awayTeam.name"></span> vs. <span data-bind="html: homeTeam.name"></span>
</div>
</td>
<!-- /ko -->
</tr>
<!-- /ko -->
</tbody>
答案 0 :(得分:2)
您可以在表格中放置多个tbody
元素,因此,如果您能够将foreach
放在table
元素上,那么您可以执行以下操作:
<table data-bind="foreach: dates">
<tr>
<td></td>
<td data-bind="html: date">
</td>
</tr>
<tbody data-bind="foreach: times">
<tr>
<td></td>
<td data-bind="html: time">
</td>
</tr>
</tbody>
</table>
答案 1 :(得分:0)
我不这么认为,但如果您在“表格模式”中使用<div>
标签,我认为您可以:
<div data-bind="foreach: dates">
<div style="display: table-row">
<div style="display: table-cell"></div>
<div style="display: table-cell" data-bind="html: date"></div>
</div>
</div>
<div data-bind="foreach: times">
<div style="display: table-row">
<div style="display: table-cell"></div>
<div style="display: table-cell" data-bind="html: time"></div>
</div>
</div>