如果我有块形式的组件:
//some-component.hbs
{{#some-component}}
<button {{action "someAction"}}>test</button>
<!-- assume you have multiple buttons here with multiple actions -->
{{/some-component}}
//some-component.js
Ember.Component.extend({
actions: {
someAction() {
alert('NOT BEING CALLED');
}
}
});
使用Ember&gt; 2.0。该动作未被调用。 如果我称之为:
{{some-component}}
并提出:
<button {{action "someAction"}}>test</button>
在some-component.hbs模板中。然后它工作。但这种方式有一些我想避免的缺点。
我已经查看了文档以及它似乎没有这种情况的所有地方。
答案 0 :(得分:1)
答案是:
{{#some-component as |component|}}
<button {{action "someAction" target=component}}>TEST</button>
{{/some-component}}
模板中的
和
switch