1
外部重複的內部重複訪問值以及具體內容如何? 這裏是我用實驗的例子:Aurelia對象的嵌套重複
this.headers = [
{text: 'Head 1', value: 'Col1'},
{text: 'Head 2', value: 'Col2'},
{text: 'Head 3', value: 'Col3'},
];
this.tableData = [
{'Col1': 1.1, 'Col2': 1.2, 'Col3': 1.3},
{'Col1': 2.1, 'Col2': 2.2, 'Col3': 2.3},
{'Col1': 3.1, 'Col2': 3.2, 'Col3': 3.3},
{'Col1': 4.1, 'Col2': 4.2, 'Col3': 4.3},
];
tableData
的生成動態地基礎上,headers
<table class="table table-striped">
<thead>
<tr>
<th repeat.for="head of headers">${head.text}</th>
</tr>
</thead>
<tbody>
<tr repeat.for="line of tableData">
<td repeat.for="head of $parent.headers">
${$parent.line[head.value]}
</td>
</tr>
</tbody>
</table>
所有我得到的回覆是空表體
<table class="table table-striped">
<thead>
<tr>
<th>Head 1</th>
<th>Head 2</th>
<th>Head 3</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
我是什麼做錯了?
感謝邁克由於一些未知的原因,我的代碼是否按預期工作現在 – Moes
它不會工作,除非你'believe',它的作品。 :) –