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

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

问题描述

我想访问流星模板中数组的第一项,我正在使用这种语法:

I want to access the first item of an array inside a meteor template, I'm using this syntax :

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

然而它似乎不起作用。我不想使用 {{#each}} 迭代值,只需从数组中选择第一个。

However it doesn't seem like it's working. I don't want to iterate through values using {{#each}}, just pick the first one from the array.

推荐答案

这只是一个语法问题,正确的如下:

This is just a problem of syntax, the correct one is the following :

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

注意数组属性之间的点括号(数组索引)表示法?

Notice the . dot between the array property and the brackets (array indexing) notation ?

以下是(隐藏)文档:

< a href =https://github.com/meteor/meteor/wiki/Using-Blaze#dotted-helpers-with-numeric-indices =noreferrer> https://github.com/meteor/meteor/ wiki / Using-Blaze#dotted-helpers-with-numeric-indices

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

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