给定这样的 JSON:
{
"network":
[
{ "name": [ "John", "Jill", "June" ] },
{ "town": [ "London", "Paris", "Tokyo" ] },
{ "age" : [ "35", "24", "14" ] }
]
}
可悲的是,我的输入数据是这种格式,我必须坚持下去。
寻找最终的 HTML 结果,例如:
<ul>
<li>John, London, is 35 years old.</li>
<li>Jill, Paris, is 24 years old.</li>
<li>June, Tokyo, is 14 years old.</li>
</ul>
(所以它实际上是按索引浏览 JSON,0,然后是 1,然后是 2:
<ul>
<li>{{name}}[0], {{town}}[0], is {{age}}[0] years old.</li>
<li>{{name}}[1], {{town}}[1], is {{age}}[1] years old.</li>
<li>{{name}}[2], {{town}}[2], is {{age}}[2] years old.</li>
</ul>
)
有没有使用handlebarsJS的本地方式来做一个模板这样的事情:
{{#each network}}<li>{{name}}[i], {{town}}[i], is {{age}}[i] years old.</li>{{/each}}
?