我有一个演示控制器:
import Ember from 'ember';
export default Ember.Controller.extend({
firstName: 'Bob',
lastName: 'Smith',
emailAddress: 'bobsmith@gmail.com',
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'));
})
});
当我在浏览器的本地主机上运行应用程序时,我打开 ember 检查器并运行:
$E.get('actualEmailAddress')
这将返回:
actualEmailAddress function is called: bobsmith@gmail.com
但是当我第二次运行它时,我得到了undefined
我跑步的时候也是这样$E.get('fullName')
它返回
executed!
"Bob Smith"
但是当我再次运行它时,它只会返回Bob Smith
,而不是console.log
为什么会这样?
谢谢!