0
下面是简单的代码(恩伯1.13.7):如何观测基地组件属性
主要成份:
export default Ember.Component.extend({
tagName: 'a',
classNameBindings: ['isTestCom:test'],
didInsertElement: function() {
this._super.apply(this, arguments);
this.$().on('click', Ember.run.bind(this, function() {
this._click();
}));
},
willDestroyElement: function() {
this._super.apply(this, arguments);
this.$().off('click');
},
_click:function(){
this.toggleProperty('isTest');
},
isTest:false,
isTestCom: Ember.computed('isTest',function(){
return this.get('isTest');
}),
});
扩展组件:
export default MainComponent.extend({
isTestChiid: Ember.computed('isTestCom',function(){
console.debug('working');
})
});
的问题是,isTestChild
从未火灾。任何想法
您是否尝试过访问组件模板中的“isTestChild”属性?只有在访问CP时才会调用该函数。让我知道它是否有效。谢谢。 – phkavitha
你是对的......没有意识到这一点 – sepetukas