从{{first}} {{last}}数组句柄-helper访问嵌套属性

时间:2018-03-18 09:21:29

标签: handlebars.js handlebarshelper

我无法弄清楚如何使用{{first}}{{last}}把手辅助工具访问数组上的嵌套属性。我有一个阵列, "test" : [{ "a" : 1, "b" : 2 }, { "a" : 2, "b" : 3 }] 我尝试使用数组语法{{{{last test}}.0.a}},但没有运气。

1 个答案:

答案 0 :(得分:0)

希望这就是你要找的东西。

{{#each test}}
 {{#if @last}} 
  {{this.a}}
 {{/if}}
{{/each}}

使用http://tryhandlebarsjs.com

进行测试