这个问题查了多久,也咨询了很多人,目前得到的结果是说,uniapp 中的这个方法有BUG,目前无解。
`//监听评论框
onLoad(){
uni.getSystemInfo({
success: (res) => {
this.setHeight = res.windowHeight-uni.upx2px(100)
//当前屏幕高度
console.log(res.windowHeight)
}
}),
uni.onKeyboardHeightChange(res =>{
//获取键盘高度
this.Keyboard=res.height;
}),
},
watch: {
Keyboard(newValue){
this.height=this.setHeight-newValue
}
}, ~~~~
`
用上面方法获取屏幕高度,和键盘高度,让两者相减得出当前文本框的高度,可是为什么获取到的高度会有变化,有时是好的,有时就会超出当前高度,文本框就会被键盘档到。
你试试在评论框的focus事件中,获取键盘高度