google.accounts.id.initialize({
client_id: '111111111111.apps.googleusercontent.com',
cancel_on_tap_outside: false,
callback: handleCredentialResponse
});
google.accounts.id.prompt();
我正在使用 Javascript 提示 UI,但我找不到为弹出窗口设置新位置的方法。 如果有任何帮助,我将不胜感激!
最佳答案
我在 api 文档中找到了解决方案。我在我的 html 文件中创建了一个 iframe;
<div id="g_id_onload"
data-prompt_parent_id="g_id_onload"
data-cancel_on_tap_outside="false"
style="position: absolute; left: 79%; top: 124px; width: 0; height: 0; z-index: 1001;">
</div>
之后,我将此 iframe 作为参数添加到 api 的初始化中:prompt_parent_id: 'g_id_onload'
google.accounts.id.initialize({
client_id: '111111111111.apps.googleusercontent.com',
cancel_on_tap_outside: false,
callback: handleCredentialResponse,
prompt_parent_id: 'g_id_onload'
});
google.accounts.id.prompt();
然后我可以随心所欲地使用样式。
您可以在此处找到详细说明:https://developers.google.com/identity/one-tap/web/guides/change-position
关于javascript - 使用 javascript 更改 Google One Tap 登录位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62385138/