【发布时间】:2015-11-21 07:22:15
【问题描述】:
如何在模板中呈现带有流星空格键 {{#each}} 的表格,并为每一行在第一列中添加行号,如下所示:
| |标题 |内容标题 |
| 1 |第一个标题 |第一个内容|
| 2 |第二个标题|第二个内容|
| 3 |第三个标题|第三个内容 |
这是我现在的每个代码:
<table class="table table-bordered table-hover">
<thead>
<tr>
<th></th>
<th>title</th>
<th>content</th>
</tr>
</thead>
<tbody>
{{#each posts}}
<tr>
<td>
*** need index for each row in this column ***
</td>
<td>
{{ title }}
</td>
<td>
{{ content }}
</td>
</tr>
{{/each}}
</tbody>
</table>
有没有办法在{{#each}} 中获取数组索引或在每次迭代中定义名为index 和index++ 的额外属性?
【问题讨论】:
标签: javascript meteor html-table spacebars