可以尝试调整inputHeight的值,让输入框的高度变小,同时在键盘弹出的时候,将输入框的高度减去键盘的高度,让输入框位置上移,不遮挡最底部的内容。可以修改如下代码:

//键盘弹出相关 let screenHeight = uni.getSystemInfoSync().screenHeight; let statusHeight= uni.getSystemInfoSync().statusBarHeight; let inputHeight = screenHeight - statusHeight - 200; // 修改输入框高度为200 // #ifdef APP-PLUS inputHeight = screenHeight - statusHeight - 300; // #endif // #ifdef H5 inputHeight = 400; // #endif

that.screenHeight = screenHeight - that.NavBar; that.postheight = inputHeight; // //that.poststyle = "height:200upx"; that.poststyle = "height:"+inputHeight+"px"; that.readstyle = "height:"+(inputHeight+30)+"px;white-space: pre-wrap;"; // #ifdef H5 //that.h5Keyboard(); // #endif // #ifdef APP-PLUS uni.onKeyboardHeightChange(res => { //监听软键盘的高度 //当点击软键盘自带的收起按钮的时候也就是会隐藏软键盘 这时候监听到的软键盘的高度就是0 、 //让输入框取消焦点 这时候再去输入内容的时候 输入框就会弹起 if (res.height == 0) { that.focalize(res.height); that.poststyle = "height:"+inputHeight+"px"; } else { // 让输入框位置上移,不遮挡最底部的内容 var keyHeight = inputHeight - res.height; that.focus(res.height); that.poststyle = "height:"+keyHeight+"px"; } }); // #endi


原文地址: https://www.cveoy.top/t/topic/faHy 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录