fix(login): 登录页 NeedCaptcha=false 时 CaptchaClick 避免 null.setAttribute 报错
页面加载时无条件调用 CaptchaClick(),但 <img id="captcha"> 仅在 NeedCaptcha=true 时渲染,导致无需验证码时 getElementById 返回 null, null.setAttribute 抛错。增加 if (!img) return 守卫,img 存在时行为不变。
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
})
|
||||
function CaptchaClick(){
|
||||
var img = document.getElementById('captcha');
|
||||
if (!img) return; // NeedCaptcha=false 时验证码 img 不渲染,避免 null.setAttribute 报错
|
||||
var newSrc = '@captchaUrl' + '&t=' + new Date().getTime();
|
||||
img.setAttribute('src', newSrc);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user