如何在Handlebars #each循环中获取索引

时间:2013-07-31 08:16:56

标签: meteor

我想在#each循环中获取Array的索引,我在网站http://handlebarsjs.com/上找到了一个描述:

“循环遍历每个项目时,您可以选择通过{{@index}}”

引用当前循环索引

但是当我使用标记{{@index}}

时,我收到了错误

错误: enter image description here

以下是我的代码:

<body>
  {{> hello}}
</body>
<template name="hello">
 {{#each arr}}
  {{@index}}:{{this}}
 {{/each}}
</template>
  Template.hello.arr = function () {
    return ["A","B","C"];
  };

我忘了什么吗?谢谢!

1 个答案:

答案 0 :(得分:1)

目前针对Meteor的Handlebars实施不支持@index。关注github

相关问题