我的 ember-simple-auth 身份验证器无法调用 super。这是为什么?

My ember-simple-auth authenticator cannot call super. Why is that?

我正在尝试实现一个身份验证器,以便它可以让我使用 OAuth 发送 client_id。在 app/authenticators/oauth-custom.js:

import Authenticator from 'simple-auth-oauth2/authenticators/oauth2';

export default Authenticator.extend({
  makeRequest: (url,  data) => {
    data.client_id = EmberENV.clientId;
    return this._super(url, data);
  }
});

然而,当我尝试登录时,这会产生错误:

TypeError: Cannot read property '_super' of undefined

源映射似乎暗示 _this 设置为 undefined

define('frontend/authenticators/oauth-custom', ['exports', 'simple-auth-oauth2/authenticators/oauth2'], function (exports, Authenticator) {

  'use strict';

  var _this = undefined;

  exports['default'] = Authenticator['default'].extend({
    makeRequest: function makeRequest(url, data) {
      data.client_id = EmberENV.clientId;
      return _this._super(url, data);
    }
  });
});

我使用的是当前最新的 ember-cli 0.2.7、ember 1.13.2、ember-simple-auth 0.8.0。有什么问题?

我对箭头函数在 ES6 中的工作方式感到困惑。使用箭头函数意味着箭头函数体内的 this 指的是其父级的 this 值。这有效:

export default Authenticator.extend({
  makeRequest: function makeRequest(url, data) {
    data.client_id = EmberENV.clientId;
    return this._super(url, data);
  }
});