【问题标题】:Using Google One Tap in Angular在 Angular 中使用 Google One Tap
【发布时间】:2021-04-02 22:47:24
【问题描述】:

我想在我的 Angular 11 应用中使用 Google One Tap。在documentation 之后,我将<script async defer src="https://accounts.google.com/gsi/client"></script> 添加到我的html 中,然后在我的app.component.html 中使用以下代码:

<div id="g_id_onload"
    data-client_id="MY_GOOGLE_CLIENT_ID"
    data-callback="handleCredentialResponse",
    data-cancel_on_tap_outside="false">
</div>

弹出窗口工作正常,但我似乎无法登录。如果我在app.component.ts 中创建函数handleCredentialResponse,我会收到以下错误:[GSI_LOGGER]: The value of 'callback' is not a function. Configuration ignored.

如果我尝试使用 JavaScript API,Typescript 会抛出以下错误:Property 'accounts' does not exist on type 'typeof google'

我应该怎么做才能在 Angular 中使用 Google One Tap?

【问题讨论】:

    标签: javascript angular typescript google-identity


    【解决方案1】:

    我知道我玩游戏有点晚了,但你仍然可以follow this blog。我认为它有效。谢谢。

    【讨论】:

      猜你喜欢
      • 2020-09-20
      • 2020-07-25
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-29
      • 2018-11-03
      相关资源
      最近更新 更多