From 03ea5881bed5e2b3e7b0c6056baea5cc009c48ec Mon Sep 17 00:00:00 2001 From: liucheng Date: Sat, 25 Jul 2026 15:09:31 +0800 Subject: [PATCH] =?UTF-8?q?fix(index):=20=E4=BF=AE=E5=A4=8D=E9=80=89?= =?UTF-8?q?=E9=A2=84=E8=AE=BE=E6=97=B6=E9=95=BF=E6=97=B6=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=90=91=E4=B8=8A=E8=B7=B3=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit input 聚焦键盘弹起时点预设,onSelectPreset 清空 customInput 触发 adjust-position 重算导致页面上跳。点预设时先失焦 input 收键盘。 Co-Authored-By: Claude --- pages/index/index.js | 8 +++++++- pages/index/index.wxml | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pages/index/index.js b/pages/index/index.js index 01d1437..2f6443c 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -28,6 +28,7 @@ Page({ planTotal: 7, planProgress: 0, showPicker: false, + pickerInputFocus: false, presets: [30, 60, 90, 120, 180, 300], customDuration: 60, customInput: '', @@ -170,7 +171,12 @@ Page({ onSelectPreset(e) { const val = e.currentTarget.dataset.value - this.setData({ customDuration: val, customInput: '' }) + // 收起键盘(失焦 input),避免清空 customInput 时触发 adjust-position 让页面向上跳 + this.setData({ pickerInputFocus: false, customDuration: val, customInput: '' }) + }, + + onPickerInputFocus() { + this.setData({ pickerInputFocus: true }) }, onCustomInput(e) { diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 67771a5..5ea2220 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -118,7 +118,9 @@ type="number" placeholder="输入秒数" value="{{customInput}}" + focus="{{pickerInputFocus}}" bindinput="onCustomInput" + bindfocus="onPickerInputFocus" />