[英]Return array item by index in a meteor spacebars template
I want to access the first item of an array inside a meteor template, I'm using this syntax : 我想访问流星模板中的数组的第一项,我正在使用这种语法:
<p>{{array[0]}}</p>
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. 我不想使用{{#each}}
迭代值,只需从数组中选择第一个。
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 ? 数组属性和括号(数组索引)表示法之间的点?
Here is the (hidden) docs for this : 这是(隐藏的)文档:
https://github.com/meteor/meteor/wiki/Using-Blaze#dotted-helpers-with-numeric-indices https://github.com/meteor/meteor/wiki/Using-Blaze#dotted-helpers-with-numeric-indices
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.