【发布时间】:2017-10-28 00:36:59
【问题描述】:
我正在尝试按照 this 文档与 Google 登录集成,但我在控制台中遇到了这个错误:
Uncaught TypeError: Cannot read property 'load' of undefinedat script.js:1
script.js:
window.gapi.load('auth2', function() {
console.log('Loaded!');
});
我大约有一半的时间收到错误,并在 Chrome 中检查网络面板,它仅在以下资源未加载时发生:
https://apis.google.com/_/scs/apps-static/_/js/k=oz.gapi.en.d2dliHDvPwE.O/m=auth2/exm=signin2/rt=j/sv=1/d=1/ed=1/am=AQ/rs=AGLTcCNGAKhVlpzmTUpjFgzBXLpLM_oEFg/cb=gapi.loaded_1
如何消除此错误?
如果有用,这里是我的index.html:
<!DOCTYPE html>
<html>
<head>
<title>Google Sign In Test</title>
<meta name="google-signin-client_id" content="*****.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script src="script.js" async defer></script>
</head>
<body>
<div class="g-signin2" data-onsuccess="onSignIn"></div>
</body>
</html>
【问题讨论】:
标签: javascript google-signin googlesigninapi