0

我有两个清单:

var one =["test","test1","test2"];
var two =["temp","temp1","temp2",""temp3","temp4"];

我在下面尝试了一些方法,但它不起作用。

<table>
{{#each one}}
  <td>{{this}}</td>
  <td>
    <select>
     {{#each two}}
       <option>{{this}}</option>
     {{/each}}
    </select>
  </td>
{{/each}}
</table>
4

2 回答 2

5

问题是“two”数组的范围超出了第一个 each 块。

试试这个:

var context = {
 one : ["test","test1","test2"],
 two : ["temp","temp1","temp2",""temp3","temp4"]
};


<table>
{{#each context.one}}
  <td>{{this}}</td>
  <td>
    <select>
     {{#each ../two}}
       <option>{{this}}</option>
     {{/each}}
    </select>
  </td>
{{/each}}
</table>
于 2017-05-01T23:09:09.680 回答
1

每个块的第二个都有语法错误。它应该{{#each two}}代替{{each}}.

于 2017-03-28T10:00:17.507 回答