我有一个具有计算属性的视图。当依赖项被更新时,观察者会正确触发,但计算属性不会。可能是什么原因?
在车把中:
{{#view viewName currencyBinding="changingValue"}}
{{view.prefix}}
{{/view}}
在视图中:
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')
当“changedValue”更新但属性没有更新时,观察者会被触发!另外,如果我在观察者中设置“前缀”:
observeCurrency: (function() {
//gets called!
console.log('observer fired');
return this.set('prefix', this.get('currency'));
}).observes('currency')
除非我对视图进行显式重新渲染,否则我的 html 不会得到更新。为什么会这样?