Javascript ember必须从组件错误调用超级方法

Javascript ember必须从组件错误调用超级方法,javascript,ember.js,handlebars.js,ember-components,ember-controllers,Javascript,Ember.js,Handlebars.js,Ember Components,Ember Controllers,我刚刚用我的自定义mixin类扩展了我的ember组件,但不幸的是,我的日志显示了一个错误 Assertion Failed: You must call `this._super(...arguments);` when overriding `init` on a framework object. Please update <cahyowhy-mini-blog@component:post-item::ember395> to call `this._super(.

我刚刚用我的自定义mixin类扩展了我的ember组件,但不幸的是,我的日志显示了一个错误

    Assertion Failed: You must call `this._super(...arguments);` when overriding `init` on a framework object. Please update <cahyowhy-mini-blog@component:post-item::ember395> to call `this._super(...arguments);` from `init`.
Error
这是我的basecontroller类

import Ember from 'ember';

export default Ember.Mixin.create({
  init(){
    //this._super(...arguments); //nek ra dipanggil neng component post item ra keno :(
    let afterRenderExist = this.afterRender !== undefined && typeof this.afterRender === "function";
    if (this.applicationRoute.documentReady && afterRenderExist) {
      Ember.run.schedule('afterRender', this, function () {
        this.afterRender();
      });
    } else if (afterRenderExist) {
      this.applicationRoute.on('onDocumentReady', this, function () {
        this.afterRender();
      });
    }
  },
但是当我试图取消注释这个语法
this.\u super(…参数)在我的基本控制器中。错误消失了

任何人都可以解决这个问题:(…

函数
init()
始终存在,并且在Ember中定义(即使不是您自己编写的)。
init()
将在后台执行一些操作,以确保Ember应用程序中的所有内容都正常工作

通过扩展自己版本的
init()
,重要的是要保留
init()
在编写任何需要编写的内容之前所做的关键功能

这就是为什么您应该调用
this.\u super(…arguments);
。否则您将基本上破坏Ember,因为您正在覆盖一些重要的功能

因此,基本上,您需要在
init()
函数的开头使用
this.\u super(…参数);
,以便一切正常工作。这就是为什么注释它会给您带来错误。如果您取消注释它,那么一切都会很好。

函数
init()
始终存在,并在Ember中定义(即使您不是自己编写的)。
init()
将在后台执行多项操作,以确保Ember应用程序中的所有内容正常工作

通过扩展自己版本的
init()
,重要的是要保留
init()
在编写任何需要编写的内容之前所做的关键功能

这就是为什么您应该调用
this.\u super(…arguments);
。否则您将基本上破坏Ember,因为您正在覆盖一些重要的功能


所以基本上,您实际上需要
这个。_super(…参数);
,在
init()的开头
函数以使一切正常工作。这就是为什么注释它会给您一个错误。如果您取消注释它,那么一切都会很好。

想法是您需要调用
init
,它是在
Ember.Component
中定义的。如果您不这样做,那么您将得到一个断言错误

Ember.Component
   basecontroller (this._super is referring to Ember.Component)
      post-item (this._super is referring to basecontroller)   

只需到达父类,即
Ember.Component
。我们需要
this.\u super
在所有位置。始终调用
this.\u super(…参数)
对于init方法是一个很好的实践。

思想是您需要调用
init
,该函数在
Ember.Component
中定义,如果不调用,您将得到一个断言错误

Ember.Component
   basecontroller (this._super is referring to Ember.Component)
      post-item (this._super is referring to basecontroller)   
只需到达父类,即
Ember.Component
。我们需要
this.\u super
在所有位置。始终调用
this.\u super(…参数)
对于init方法是一种很好的做法