简体   繁体   English

在流星空间键模板中按索引返回数组项

[英]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.

相关问题 流星显示模板空间栏中数组的第一个元素 - meteor display first element of array in template spacebars Meteor:在空格键中获取模板名称 - Meteor: get template name in spacebars 流星-模板助手参数(空格键) - Meteor - template helpers argument (spacebars) Blaze模板助手仅在空格键中返回,在Meteor / Mongo中的每个循环中 - Blaze template helper only returning on in a Spacebars each loop in Meteor/Mongo 用户空格键和模板助手在Meteor中随机加载为页面背景 - User Spacebars and Template Helpers to load random as page background in Meteor 跟踪 Meteor Spacebars Collection (blaze) 的偶数/奇数索引 - Tracking even/odd index of Meteor Spacebars Collection (blaze) 流星数据上下文,将数组传递到每个空格键循环中 - Meteor data context, passing array into each Spacebars loop Meteor JS:如何使用Spacebars显示从Meteor Collection中检索到的数组内的内容 - Meteor JS: How to use Spacebars to display contents inside an array retrieved from Meteor Collection 如何在每个循环中获取 Meteor 模板中数组的索引? - How can I get the index of an array in a Meteor template each loop? 如何渲染带有流星空格键模板的表和每行的行号? - How Do I Render Table With Meteor Spacebars Template and Row Number For Each Row?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM