我将Google picker API集成到我的应用程序中。我正在遵循官方文档Google Picker API
我已经成功地完成了我的工作,但是在添加了下面的代码之后,我无法使用类方法和变量。获取无法读取未定义错误的属性
gapi.load('auth', {'callback': this.onAuthApiLoad.bind(a)});完整的代码是:
onApiLoad() {
var a= this;
gapi.load('auth', {'callback': this.onAuthApiLoad.bind(a)});
gapi.load('picker');
}
onAuthApiLoad() {
gapi.auth.authorize(
{
'client_id': this.clientId,
'scope': this.scope,
'immediate': false
},
this.handleAuthResult);
}
handleAuthResult(authResult) {
if (authResult && !authResult.error) {
if (authResult.access_token) {
var pickerBuilder = new google.picker.PickerBuilder();
var picker = pickerBuilder.
enableFeature(google.picker.Feature.NAV_HIDDEN).
setOAuthToken(authResult.access_token).
addView(google.picker.ViewId.DOCS).
setCallback(this.myFun).
build();
picker.setVisible(true);
}
}
}
myFun(e){
}发布于 2018-01-03 02:01:51
我添加了以下行来处理身份验证请求
this.handleAuthResult.bind(this)https://stackoverflow.com/questions/48065586
复制相似问题