我用li
元素包装我的组件。没关系。但我正在尝试将该操作添加到wrapped
元素中。但是出现错误。将action
添加到包裹元素的正确方法是什么?如何在EmberJs中添加`action`到组件元素?
任何一个帮助我吗?
我的组件:
<ul>
{{#each cardList as |card index |}}
{{
cs2i-cardcomponent
card=card
index=index
enableNext='enableNext'
tagName="li"
{{action "selectCard card index" }}//not works. trying to pass card and index to selected card in actions object in componet.js.
}}
{{/each}}
</ul>
我的组件JS:
import Ember from 'ember';
export default Ember.Component.extend({
tagName:"",
firstBalanceType : '',
firstBalanceAmount : '',
lastBalanceType : '',
lastBalanceAmount : '',
isSelected : false,
actions : {
selectCard : function(card,index) {
this.set('selectedIndex', index);
this.toggleProperty('isSelected');
this.sendAction('enableNext', card);
}
}
});
它'{{行动 “的SelectCard” 证指数}}' – Lux
还没作品..我不能值传递给操作? – user2024080
@Lux - brase看起来与syntex不同。出现错误'Expected'CLOSE_RAW_BLOCK','CLOSE','CLOSE_UNESCAPED','OPEN_SEXPR','CLOSE_SEXPR','ID','OPEN_BLOCK_PARAMS','STRING ','NUMBER','BOOLEAN','UNDEFINED', 'NULL','DATA','OPEN'' – user2024080