Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ember.js 呼叫“a”;“基类”;来自扩展对象的方法_Ember.js - Fatal编程技术网

Ember.js 呼叫“a”;“基类”;来自扩展对象的方法

Ember.js 呼叫“a”;“基类”;来自扩展对象的方法,ember.js,Ember.js,假设我有这个: App.ControllerMixin = Ember.Mixin.create({ setupController : function (entry) { ... } }); App.BaseEditController = Ember.ObjectController.extend(App.ControllerMixin, { startEditing: function () { ... this.

假设我有这个:

App.ControllerMixin = Ember.Mixin.create({
    setupController : function (entry) {
        ...
    }
});

App.BaseEditController = Ember.ObjectController.extend(App.ControllerMixin, {
    startEditing: function () {
        ...
        this.setupController(entry);
    },

});

App.ServicesEditController = App.BaseEditController.extend(App.ServicesMixin, {
    setupController : function (entry) {
    }
});

如何从
servicesditcontroller.setupController
调用
ControllerMixin.setupController

您可以使用
this.\u super()
从超类调用方法。通常,最好将此调用添加到要重写的每个方法中

App.ServicesEditController = App.BaseEditController.extend(App.ServicesMixin, {
    setupController : function (entry) {
      this._super(entry);
    }
});
根据我的建议,在每个重写方法中添加此调用,这是视图的Mixin示例。如果你的Mixin覆盖了didInsertElement,你应该总是添加一个对this的调用如果应用了多个mixin,这将确保调用“所有”didInsertElement实现。

App.SomeViewMixin = Ember.Mixin.create({
  didInsertElement : function(){
    this._super();
    // ... perform your logic
  }
});

让我直截了当地说:你是说从
setupController
中调用的
this.\u super(entry)
将自动调用super类上的
setupController
方法吗?这意味着,
\u super
调用名为调用它的方法的方法?魔法!:)如果重写控制器中的Mixin方法,则此.\u super()似乎不会调用Mixin方法。我该怎么做?