Android 监听输入框焦点事件无效 需要监听监听resize
mounted() {if(Utils.iosShell){ //是否是ioswindow.addEventListener('focusout', () => {this.recoverScroll();})}else{const innerHeight = window.innerHeight;window.addEventListener('resize', () => {const newInnerHeight = window.innerHeight;if (innerHeight > newInnerHeight) {// 键盘弹出事件处理} else {// 键盘收起事件处理this.recoverScroll()}});}},methods: {//- 回复滚动条位置recoverScroll(){// 获取滚动的容器高度const container = document.getElementsByClassName("scroll-container")[0]const scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0container.scroll(0, scrollTop)},}
如果觉得《移动端软键盘弹起页面无法滚动问题》对你有帮助,请点赞、收藏,并留下你的观点哦!