Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.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 我的ember简单身份验证程序无法调用super。为什么呢?_Ember.js_Ember Simple Auth - Fatal编程技术网

Ember.js 我的ember简单身份验证程序无法调用super。为什么呢?

Ember.js 我的ember简单身份验证程序无法调用super。为什么呢?,ember.js,ember-simple-auth,Ember.js,Ember Simple Auth,我正在尝试实现一个验证器,这样它就可以让我用OAuth发送一个客户端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.

我正在尝试实现一个验证器,这样它就可以让我用OAuth发送一个
客户端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:无法读取未定义的属性“\u super”

源代码映射似乎表明
\u此
设置为
未定义

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);
  }
});