我正在制作一个网站,我正在使用 google 标志 (oauth 2),我希望在用户登录时出现一个 div,另一个 div 消失。这是我目前的代码:
<meta name="google-signin-client_id" content="20575446019-pm4np7uisq70q5dct2kmbtkq246rmhsg.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script>
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
console.log('Name: ' + profile.getName());
document.getElementById('lol').style.display = 'none';
document.getElementById('app').style.display = 'inline-block';
</script>
<div id="lol" class="lol">
<h1>I want this to appear when user enters page but disappear on google sign in.</h1>
<p>Blah Blah Blah and other content in this div</p>
<div>
<div id="app" class="app" display="none">
<h1> I want this div to not be visible when the user enters the page but be visible after user does the google sign in</h1>
<p>Blah Blah Blah and other content in this div</p>
<div class="g-signin2" data-onsuccess="onSignIn" data-width="220" data-height="50" data-longtitle="true"></div>
它工作不正常,我不知道出了什么问题... 感谢您的帮助!!!