diff --git a/pages/template/navbar-lite/navbar-lite.uvue b/pages/template/navbar-lite/navbar-lite.uvue index e24670bde3b347559f5c949034b537f449edda11..73ec68cc6f502edfbc8c9de6a1bc687065d94322 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); } }