【发布时间】: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