相关疑难解决方法(0)

Google 的登录按钮在加载后会调整大小

我正在关注https://developers.google.com/identity/gsi/web/guides/display-button#javascript将 Google 登录添加到我的 ReactJS 应用程序中。

我添加了

 <script>
      function handleCredentialResponse(response) {
        console.log("Encoded JWT ID token: " + response.credential);
      }

      window.onload = function () {
        google.accounts.id.initialize({
          client_id: "YOUR_GOOGLE_CLIENT_ID",
          callback: handleCredentialResponse,
        });
        google.accounts.id.renderButton(
          document.getElementById("buttonDiv"),
          { theme: "filled_blue", size: "large", shape: "pill" } // customization attributes
        );
        google.accounts.id.prompt(); // also display the One Tap dialog
      };
</script>
Run Code Online (Sandbox Code Playgroud)

在 中index.html,在我的组件中,我有一个<div id="buttonDiv"></div>.

但是,当我重新加载页面时会发生以下情况:

在此输入图像描述

加载的初始按钮是正确的,但不知何故调整了大小。我在调试器中暂停了JS执行,发现最初的按钮纯粹是divs,但是调整大小后,它用了aniframe代替。

reactjs google-signin google-identity

13
推荐指数
2
解决办法
5249
查看次数

标签 统计

google-identity ×1

google-signin ×1

reactjs ×1