【发布时间】:2017-12-30 05:30:59
【问题描述】:
我正在运行这段代码,有时我得到一个错误,其他我没有,我真的不明白为什么。
let promiseLogIn = new Promise(function(reject,resolve){
gapi.auth.authorize(authData , function(response) {
var authButton = document.getElementById('auth-button');
if (response.error) {
console.log("AuthBad");
resolve();
authButton.hidden = false;
}
else {
console.log("AuthGood");
reject();
authButton.hidden = true;
}
});
});
我在我的 html 文件中加载 lib,如下所示:
<script src="https://apis.google.com/js/client.js?onload=authorize"></script>
<script src="sources/scripts/dist/bundle.js"></script>
其中 bundle.j 是我拥有所有已编译 ts 文件的位置。
【问题讨论】:
-
你确定要在打字稿下标记这个吗?
-
您确定您正确加载了 gapi 库吗?
-
@Aron 这是使用打字稿构建的,我应该如何正确加载它?
-
@Aron 在我的 html 中我有: 其中 bundle.js ths Ts 编译
-
请也使用脚本标签编辑您的问题
标签: typescript google-api google-api-js-client