爲什麼此代碼中的「fullName」函數執行兩次?emberjs - 財產火災兩次
Person = Ember.Object.extend({
// these will be supplied by `create`
firstName: null,
lastName: null,
fullName: function() {
console.log('Full name function...');
var firstName = this.get('firstName');
var lastName = this.get('lastName');
return firstName + ' ' + lastName;
}.property('firstName', 'lastName')
});
App.tom = Person.create({
firstName: "Tom",
lastName: "Dale"
});
App.UsersView = Ember.View.create({
templateName: 'users',
users: [App.tom]
});
在谷歌鉻控制檯後來:
App.tom.set('firstName', 'John')
此輸出登錄兩次。
文本'全名功能'被打印兩次 – mprcela 2012-07-18 06:32:01