解决思路:
在页面加载完成,软键盘未升起时获取视窗真实高度, 然后监听页面高度, 如发生变化则重新设置body或html标签的高度为一开始获取的视窗高度.
this.Height = window?.screen?.orientation?.type === 'portrait-primary' ? document.body.offsetHeight : document.body.offsetWidth
this.changeHeight()
window.onresize = () => {
this.changeHeight()
}
screen.orientation.addEventListener('change', () => {
this.changeHeight()
})
changeHeight() {
if (window?.screen?.orientation?.type === 'landscape-primary') {
document.body.style.height = this.Height * 2 + 'px'
} else {
document.body.style.height = this.Height + 'px'
}
},
