0
我有下表:轮换班,Knockout.JS
<table class="table" id="calls_table">
<thead>
<tr>
<th class="round-bg header">Val1</th>
<th class="rep-bg header">Val2</th>
<th class="rep-bg header">Val3</th>
</tr>
</thead>
<tbody data-bind="template: {name: 'call-template', foreach: calls}">
</tbody>
</table>
<script type="text/html" id="call-template">
<tr class="alt">
<td><a data-bind="attr: {href: url}, text: v1" class="simp" href=""></a></td>
<td><a data-bind="attr: {href: url}, text: v2" class="simp" href=""></a></td>
<td data-bind="text: v3"></td>
</tr>
</script>
的问题是如何添加类的交替为TR的?像:class ='alt',class ='' - 请指教。
当使用KO构建表时,这将在第一次渲染表时生效。但是如果你做了任何导致表格被重新渲染(例如,改变任何值)的事情,你必须确保你再次调用它。 –
photo_tom,是的,这也是如此。感谢您的支持。 –