javascript - 自定义“g-signin2”样式按钮
问题描述
我正在寻找更改我的谷歌登录按钮的背景。这是我用来为用户签名的客户端代码。
<div class="g-signin2" id="googleSignIn" data-onsuccess="onSignIn"></div>
function onSignIn(googleUser) {
let profile = googleUser.getBasicProfile();
let email = profile.getEmail();
let name = profile.getName();
let imgurl = profile.getImageUrl();
console.log(imgurl);
document.querySelector(".g-signin2").addEventListener("click", () => {
console.log(profile);
});
document.getElementById("googleSignIn").addEventListener("click", () => {
let fd = new FormData();
fd.append("email", email);
fd.append("name", name);
fd.append("image", imgurl);
fetch("index.php?action=security&fc=googleValidation", {
method: "POST",
body: fd,
})
.then((response) => response.json())
.then((data) => {
if (data == "connectUser" || data == "userCreated") {
location.href = "index.php?action=profil";
}
})
.catch((err) => {});
});
}
我试图在我的 js 代码中修改样式,但问题是我得到了我想要的(样式)但是如果我使用它,验证器就不再起作用了
setTimeout(function () {
document.querySelector(".g-signin2").style.background = "url('public/img/Google.svg') no-repeat";
document.querySelector(".abcRioButtonContentWrapper").style.display = "none";
document.querySelector(".abcRioButton").style.height = "";
document.querySelector(".abcRioButtonLightBlue").style.height = "";
document.querySelector(".abcRioButton").style.width = "45px";
}, 600);
谷歌提供了一个如何构建自定义按钮的示例,我已经尝试过了,但似乎对我不起作用。是否可以自定义“g-sinin2”?
解决方案
推荐阅读
- python - 如何使用python获取某个路径的设备文件和分区号?
- javascript - react-native-map 标记图像源来自一个状态
- php - 根据子类别显示相关产品 - woocommerce
- angular - Angular 5:“任何[]”类型上不存在属性“描述”
- django - 如何防止因 SuspiciousOperation 错误而发送的管理员电子邮件
- python - Python sys.stdout.flush() 似乎不起作用
- keras - 变分自动编码器:编码器是否必须具有与解码器相同的层数?
- java - AWS Lambda 中的资源释放
- c++ - 在 VS 2005 中获取编译器错误'二进制'<<':找不到运算符'
- jquery - 使用 JQUERY MODAL PHP 传递变量