Ember.js如何从子类调用超类或基类方法?

时间:2015-11-04 05:20:53

标签: ember.js

当我尝试从ember.js中的子类调用基类方法时,我收到以下错误

断言失败:Ember.Object.create不再支持定义调用_super

的方法
App.BaseClass = Ember.Object.extend({
 sayHello: function(){
   //my code
}
});

App.SubClass = App.BaseClass.extend({
//some code here 

sayHellow: function(){
//some code of subclass
.
.
.
this_super(); // This causes error: Assertion failed: Ember.Object.create no //longer supports defining methods that call _super
}
});

1 个答案:

答案 0 :(得分:0)

你应该使用this._super()

sayHello: function(){

//some code of subclass

.

.

.

this._super(); 

// This causes error: Assertion failed: Ember.Object.create no //longer supports defining methods that call _super

}

});