函数 Ember.computed() 和 function().属性() 有什么区别?
What is the difference between the function Ember.computed() and function().property()?
App.Person = Ember.Object.extend({
// these will be supplied by `create`
firstName: null,
lastName: null,
fullName: function() {
return this.get('firstName') + ' ' + this.get('lastName');
}.property('firstName', 'lastName'),
fullName:Ember.computed('firstName','lastName', function() {
return this.get('firstName') + ' ' + this.get('lastName');
}
});
函数 Ember.computed() 和 function().属性() 有什么区别?
为什么有两种方法(函数)将函数声明为计算属性?
有什么区别,好处?
Ember.computed()
是一个(干净的)alternative to function().property()
in case you are disabling prototype extensions。
App.Person = Ember.Object.extend({
// these will be supplied by `create`
firstName: null,
lastName: null,
fullName: function() {
return this.get('firstName') + ' ' + this.get('lastName');
}.property('firstName', 'lastName'),
fullName:Ember.computed('firstName','lastName', function() {
return this.get('firstName') + ' ' + this.get('lastName');
}
});
函数 Ember.computed() 和 function().属性() 有什么区别?
为什么有两种方法(函数)将函数声明为计算属性? 有什么区别,好处?
Ember.computed()
是一个(干净的)alternative to function().property()
in case you are disabling prototype extensions。