我正在尝试在另一个内部使用迭代助手。但是内部帮助程序不会输出任何内容。
那是把手模板:
{{#people}}
<h4>{{firstName}} {{lastName}}</h4>
{{#students}}
<h3>{{firstName}} {{lastName}}</h3>
{{/students}}
{{/people}}
那就是我的JSON:
{
people : [
{ firstName: "Yehuda", lastName: "Katz" },
{ firstName: "Carl", lastName: "Lerche" },
{ firstName: "Alan", lastName: "Johnson" }
],
students: [
{ firstName: "Mike", lastName: "Smith" },
{ firstName: "Dan", lastName: "Knight" },
{ firstName: "Griffin", lastName: "Smith" }
]
}
该问题的解决方案是什么?在此处在线快速尝试代码:http : //tryhandlebarsjs.com/
表达式{{#people}}
...{{/people}}
引起三个上下文:
{ firstName: "Yehuda", lastName: "Katz" },
{ firstName: "Carl", lastName: "Lerche" },
{ firstName: "Alan", lastName: "Johnson" }
因此在这些情况下都没有学生,这就是为什么内在表达式{{#students}}
...{{/students}}
没有给出输出的原因。
您能否详细说明您要达到的目标?
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句