我有一个有计算属性的视图。当依赖关系得到更新时,观察者会正确触发,但计算属性不会。原因是什么?Ember计算属性不起作用
在车把:
{{#view viewName currencyBinding="changingValue"}}
{{view.prefix}}
{{/view}}
在视图中:当 'changingValue' 更新
prefix: (function() {
//does not get called!!!
console.log('computed property fired');
return this.get('currency');
}).property('currency')
observeCurrency: (function() {
//gets called!
return console.log('observer fired');
}).observes('currency')
观察员被激发,但属性不! 另外,如果我在设定观察者“前缀”:
observeCurrency: (function() {
//gets called!
console.log('observer fired');
return this.set('prefix', this.get('currency'));
}).observes('currency')
我的HTML没有得到更新,除非我的观点的明确重新呈现。为什么会发生?
小提琴例子? – Manoharan
除非我遗漏了一些你不必包装你的计算属性,它应该像'computedPropertyName:function {...} .property('dependency')' – MilkyWayJoe