From 20ac8afe70f1bc41a8937941f9bfec75df8fc5c4 Mon Sep 17 00:00:00 2001 From: yanyilin Date: Wed, 29 May 2024 12:46:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9input=E6=A1=86=E5=9C=A8?= =?UTF-8?q?=E8=BD=AF=E9=94=AE=E7=9B=98=E9=AB=98=E5=BA=A6=E5=8F=98=E5=8C=96?= =?UTF-8?q?=E6=97=B6=E6=98=BE=E7=A4=BA=E4=BD=8D=E7=BD=AE=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/template/navbar-lite/navbar-lite.uvue | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pages/template/navbar-lite/navbar-lite.uvue b/pages/template/navbar-lite/navbar-lite.uvue index e24670bd..73ec68cc 100644 --- a/pages/template/navbar-lite/navbar-lite.uvue +++ b/pages/template/navbar-lite/navbar-lite.uvue @@ -37,7 +37,7 @@ - + @@ -53,6 +53,7 @@ navigationBarTextColor: '#000', indexView: 0, windowHeight: 0, + inputRemainHeight: 0, //输入框距离底部的距离 inputBottom: '0px' } }, @@ -105,9 +106,7 @@ 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); + let bottom = (this.inputRemainHeight > e.detail.height)?0:(e.detail.height-this.inputRemainHeight); this.inputBottom = `${bottom}px`; }, // 自动化测试 @@ -120,10 +119,12 @@ }, }, onReady() { - this.windowHeight = uni.getWindowInfo().windowHeight; + let windowHeight = uni.getWindowInfo().windowHeight; + this.remainHeight = windowHeight - (uni.getElementById('input')?.getBoundingClientRect()?.bottom??windowHeight); }, onResize() { - this.windowHeight = uni.getWindowInfo().windowHeight; + let windowHeight = uni.getWindowInfo().windowHeight; + this.remainHeight = windowHeight - (uni.getElementById('input')?.getBoundingClientRect()?.bottom??windowHeight); } } -- GitLab