Javascript 把手上的索引运算符表示意外标记,

Javascript 把手上的索引运算符表示意外标记,,javascript,ember.js,handlebars.js,Javascript,Ember.js,Handlebars.js,我在我的ember应用程序中有#每个循环,我想知道循环的索引,所以我尝试像这样使用{{@index}}: <script type="text/x-handlebars" data-template-name="column"> <ul> {{#each item in controller}} {{@index}} {{item-rows currentItem=item}} {{/each}} </ul> </script> 我的ember.

我在我的ember应用程序中有#每个循环,我想知道循环的索引,所以我尝试像这样使用{{@index}}:

<script type="text/x-handlebars" data-template-name="column">
<ul>
{{#each item in controller}}
{{@index}}
{{item-rows currentItem=item}}
{{/each}}
</ul>
</script>

我的ember.js版本是rc8,车把是1。我需要一个解决方案来查找#each的索引。

您可以从
#each
帮助程序的
itemViewClass
获取contentIndex

{{#each itemViewClass="Em.View"}}
   <h3 class="row">{{name}} - <small>{{view.contentIndex}}</small></h3>    
{{/each}}
{{#each itemViewClass=“Em.View”}
{{name}}-{view.contentIndex}
{{/每个}}

你知道为什么车把和灰烬一起使用会导致这种情况吗?根据车把主页上的
@index
应该可以正常工作。为什么余烬会打破这个?@Sukima AFAIK,余烬不使用把手助手。Ember已经为每个、
如果
等等构建了自己的帮助程序。。。
{{#each itemViewClass="Em.View"}}
   <h3 class="row">{{name}} - <small>{{view.contentIndex}}</small></h3>    
{{/each}}