Ember.js 使用每个辅助对象从集合中删除的上一项

Ember.js 使用每个辅助对象从集合中删除的上一项,ember.js,Ember.js,我正在使用每个帮助器,需要访问上一个项目 {{#each item in items}} {{previous}} {{/each}} {{#each items as |item index|}} {{some-component item=item index=index collection=items}} {{/each}} 如何获取上一个项目?我切换到每个帮助器的新形式,它为您提供索引,并将其和项目一起传递到一个组件中,然后该组件计算上一个项目 {{#each item i

我正在使用每个帮助器,需要访问上一个项目

{{#each item in items}}
  {{previous}}
{{/each}}
{{#each items as |item index|}}
  {{some-component item=item index=index collection=items}}
{{/each}}

如何获取上一个项目?

我切换到每个帮助器的新形式,它为您提供索引,并将其和项目一起传递到一个组件中,然后该组件计算上一个项目

{{#each item in items}}
  {{previous}}
{{/each}}
{{#each items as |item index|}}
  {{some-component item=item index=index collection=items}}
{{/each}}

我很想知道是否有更巧妙的方法。也许我们可以在每个助手中添加上一个:)我认为这是一个很好的解决方案。如果
item
是一个模型,并且属于某个父项,则可以添加一个计算属性,该属性直接向模型中查找上一个项