【发布时间】:2018-06-04 03:08:09
【问题描述】:
这在某种程度上是我的 TD 未呈现的把手的一个简单问题。
我的车把:
<table class="defaultTable" style="width:90mm;">
<colgroup>
{{#each cols}}
<col style="width:{{this.width}}mm;">
{{/each}}
</colgroup>
<tbody>
{{#each rows}}
<tr>
{{#each cols}}
<td>{{this.content}}</td>
{{/each}}
</tr>
{{/each}}
</tbody>
</table>
我的数据:
cols = [{
width: 45,
content: ''
},{
width: 45,
content: ''
}];
Rows = [{},{}];
我的输出
<table class="defaultTable" style="width:90mm;">
<colgroup>
<col style="width:45;">
<col style="width:45;">
</colgroup>
<tbody>
<tr>
</tr>
<tr>
</tr>
</tbody>
</table>
为什么 tds 没有被渲染?我是否错过了有关每个循环应如何工作的内容?
谢谢。
【问题讨论】:
-
当您在
{{#each}}块内时,您需要提高上下文级别。请参阅:handlebarsjs.com/#paths。另外,请确保您与命名rows的方式一致 - 始终或从不将第一个字符大写。
标签: handlebars.js each