【问题标题】:Ember.js how to call super class or base class method from subclass?Ember.js 如何从子类调用超类或基类方法?
【发布时间】:2015-11-04 05:20:53
【问题描述】:

当我尝试从 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
}
});

【问题讨论】:

  • this_super 是错字吗? HelloHellow 是错字吗?

标签: ember.js


【解决方案1】:

你应该使用 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

}

});

【讨论】:

  • 亲爱的我已经在使用 this._super() 导致断言失败错误
  • 你使用 this_super()
猜你喜欢
  • 1970-01-01
  • 2011-12-08
  • 1970-01-01
  • 2012-04-18
  • 1970-01-01
相关资源
最近更新 更多