From 42e9b7c15f746eaca8ab9afe2475e5c87024eca9 Mon Sep 17 00:00:00 2001 From: Yer11214 <17633066053@163.com> Date: Sun, 20 Sep 2026 15:26:13 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(verify-code):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E8=BE=93=E5=85=A5=E5=A4=84=E7=90=86=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20APP=20=E7=AB=AF=E6=A0=B7=E5=BC=8F=E5=B1=82=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 兼容多端事件对象,从 detail.value 或 target.value 中安全取值 - 过滤非数字字符并按 size 截断,避免非法输入与 --- components/verify-code/verify-code.vue | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/components/verify-code/verify-code.vue b/components/verify-code/verify-code.vue index 4d652d7..be01875 100644 --- a/components/verify-code/verify-code.vue +++ b/components/verify-code/verify-code.vue @@ -167,7 +167,8 @@ function getCodeCursorLeft() { // 输入框输入变化的回调 function handleInput(e: any) { - const value = e.detail.value + const inputValue = e?.detail?.value ?? e?.target?.value ?? '' + const value = String(inputValue).replace(/\D/g, '').slice(0, props.size) code.value = value cursorVisible.value = value.length !== props.size emit('update:modelValue', value) @@ -270,13 +271,30 @@ function codeFormat(val: string | undefined, isPassword: boolean): string { position: absolute; top: 50%; left: 50%; - font-size:52rpx; + z-index: 1; + color: #333; + font-size: 52rpx; transform: translate(-50%, -50%); } } } } +/* #ifdef APP-PLUS */ +/* APP 中让自绘验证码位于透明输入框上方;点击仍由 input-ground 触发聚焦。 */ +.xt__input { + z-index: 1; +} + +.xt__input-ground { + z-index: 2; +} + +.xt__cursor { + z-index: 3; +} +/* #endif */ + @keyframes cursor { 0% { opacity: 1;