我有一個演示控制器:爲什麼燼計算屬性只能在燼檢查器中執行一次?
import Ember from 'ember';
export default Ember.Controller.extend({
firstName: 'Bob',
lastName: 'Smith',
emailAddress: '[email protected]',
fullName: Ember.computed('firstName', 'lastName', function() {
console.log('executed!');
return `${this.get('firstName')} ${this.get('lastName')}`;
}),
actualEmailAddress: Ember.computed('emailAddress', function() {
console.log('actualEmailAddress function is called: ', this.get('emailAddress'));
})
});
當我運行的應用程序在本地主機上的瀏覽器,我打開燼檢查並運行:
$E.get('actualEmailAddress')
這將返回:
actualEmailAddress function is called: [email protected]
但是當我第二次運行它時,我只是得到undefined
當我運行$E.get('fullName')
它返回
executed!
"Bob Smith"
但同樣的事情,那麼,當我再次運行它它只返回Bob Smith
,而不是console.log
這究竟是爲什麼?
謝謝!