我正在尝试遵循this https://developers.google.com/identity/sign-in/web/devconsole-project与 Google 登录集成的文档,尽管我在控制台中遇到了此错误:
Uncaught TypeError: Cannot read property 'load' of undefined
at script.js:1
script.js
:
window.gapi.load('auth2', function() {
console.log('Loaded!');
});
我大约有一半的时间收到错误,并检查 Chrome 中的网络面板,只有当以下资源为not loaded:
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>
尝试向脚本标记添加 onload 事件。因此,将您的脚本标签更改为
<script src="https://apis.google.com/js/platform.js?onload=myFunc" async defer></script>
然后将您的代码包装在回调函数中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)