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