函数Ember.computed()和function()。property()有什么区别?

时间:2015-02-04 01:10:20

标签: ember.js

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()。property()有什么区别?

为什么有两种方法(函数)将函数声明为计算属性? 有什么区别,好处?

1 个答案:

答案 0 :(得分:1)

如果你是alternative

Ember.computed()是{干净的} disabling prototype extensionsfunction().property()