【问题标题】:Handlebars @index when accessing other objects elements访问其他对象元素时的把手@index
【发布时间】:2015-11-15 18:02:34
【问题描述】:

我正在尝试访问与我正在迭代的数组具有相同索引的另一个数组字段。

{{#each array}}
    {{ otherArray.{{@index}}.myField }}
{{/each}}

以下可能吗?

【问题讨论】:

    标签: templates template-engine handlebars.js


    【解决方案1】:

    查找助手完成了这项工作:

    {{#each array}}
        {{#with (lookup ../otherArray @index)}}
            {{myField}}
        {{/with}}
    {{/each}}
    

    【讨论】:

      猜你喜欢
      • 2017-12-10
      • 2012-12-14
      • 2012-04-25
      • 1970-01-01
      • 2018-09-09
      • 2023-03-24
      • 2020-04-05
      • 2022-01-23
      • 2013-06-22
      相关资源
      最近更新 更多