From 5ab3890f43aacf1fd6b70d9ae0ea2eb691a4eef2 Mon Sep 17 00:00:00 2001 From: yanyilin Date: Mon, 20 May 2024 12:59:18 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BA=E4=BE=8Binput=E6=A1=86=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E4=BB=A3=E7=A0=81=E6=8E=A7=E5=88=B6=E4=B8=8D=E8=A2=AB?= =?UTF-8?q?=E8=BD=AF=E9=94=AE=E7=9B=98=E9=81=AE=E6=8C=A1=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E5=A4=9A=E7=A7=8D=E5=9C=BA=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/template/navbar-lite/navbar-lite.uvue | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pages/template/navbar-lite/navbar-lite.uvue b/pages/template/navbar-lite/navbar-lite.uvue index 03afcbdc..1b06e34a 100644 --- a/pages/template/navbar-lite/navbar-lite.uvue +++ b/pages/template/navbar-lite/navbar-lite.uvue @@ -37,7 +37,7 @@ - + @@ -52,6 +52,7 @@ isLeft: false, navigationBarTextColor: '#000', indexView: 0, + windowHeight: 0, inputBottom: '0px' } }, @@ -100,11 +101,14 @@ ChangeView(e:UniRadioGroupChangeEvent){ this.indexView = parseInt(e.detail.value) }, - onInputFocus(e:UniInputFocusEvent ) { - this.inputBottom = `${e.detail.height}px`; - }, - onInputBlur(e:UniInputBlurEvent) { + onInputBlur(_:UniInputBlurEvent) { this.inputBottom = '0px'; + }, + onInputKeyboardChange(e:UniInputKeyboardHeightChangeEvent) { + let inputBottom = e.target?.getBoundingClientRect()?.bottom??this.windowHeight; + let remainHeight = this.windowHeight - inputBottom; + let bottom = (remainHeight > e.detail.height)?0:(e.detail.height-remainHeight); + this.inputBottom = `${bottom}px`; }, // 自动化测试 getLifeCycleNum() : number { @@ -114,6 +118,12 @@ setLifeCycleNum(num : number) { setLifeCycleNum(num) }, + }, + onReady() { + this.windowHeight = uni.getWindowInfo().windowHeight; + }, + onResize() { + this.windowHeight = uni.getWindowInfo().windowHeight; } } -- GitLab