在流星空格键模板中按索引/变量返回数组项 [英] Return array item by index/variable in a meteor spacebars template

查看:435
本文介绍了在流星空格键模板中按索引/变量返回数组项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何访问流星模板中数组的X项?

How can I access the X item of an array inside a meteor template?

感谢在流星空格键模板我知道如何针对特定索引执行此操作:

Thanks to Return array item by index in a meteor spacebars template I know how to do that for a specific index:

<p>{{array.[0]}}</p>

但是我的问题是如何为运行时定义的索引执行此操作. 假设X已定义且具有有效值.为什么这对我不起作用?

But my question is how to do that for a runtime defined index. Let say that X is defined and with a valid value. Why is this not working for me?

<p>{{array.[X]}}</p>

推荐答案

您可以尝试

<p>{{array.[index]}}</p> 例如. <p>{{array.[0]}}</p>

{{#each getArray}}
    <div class="item" data-value="{{someHelper @index}}">
        {{this}}
    </div>
{{/each}}

这篇关于在流星空格键模板中按索引/变量返回数组项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆