From a871bcb9fe0467180a52193de1656a89dcd006e7 Mon Sep 17 00:00:00 2001 From: hjhan Date: Fri, 31 Jul 2026 09:10:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(login):=20=E7=99=BB=E5=BD=95=E9=A1=B5=20Nee?= =?UTF-8?q?dCaptcha=3Dfalse=20=E6=97=B6=20CaptchaClick=20=E9=81=BF?= =?UTF-8?q?=E5=85=8D=20null.setAttribute=20=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 页面加载时无条件调用 CaptchaClick(),但 仅在 NeedCaptcha=true 时渲染,导致无需验证码时 getElementById 返回 null, null.setAttribute 抛错。增加 if (!img) return 守卫,img 存在时行为不变。 --- YLErpWeb/Views/Account/Login.cshtml | 1 + 1 file changed, 1 insertion(+) diff --git a/YLErpWeb/Views/Account/Login.cshtml b/YLErpWeb/Views/Account/Login.cshtml index c3e8ae00..f71d0ea7 100644 --- a/YLErpWeb/Views/Account/Login.cshtml +++ b/YLErpWeb/Views/Account/Login.cshtml @@ -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); }