手机键盘弹起之后遮挡输入框

输入框被遮挡问题: 

安卓手机遇到后,解决方案:(基于Vue 项目)

1 window.addEventListener('resize', () => {
2       //延迟出现是因为有些 Android 手机键盘出现的比较慢
3       window.setTimeout(() => {
4         this.$refs.replayInp.scrollIntoViewIfNeeded();
5       }, 100);
6     });
scrollIntoViewIfNeeded: 用来将不在浏览器窗口的可见区域内的元素滚动到浏览器窗口的可见区域。 如果该元素已经在浏览器窗口的可见区域内,则不会发生滚动。 Element.scrollIntoView() 点击查看

IOS手机遇到后得解决方案:

onFocusInput(){
      setTimeout(function(){
        document.body.scrollTop = document.body.scrollHeight;  //获取高度并给页面一个滚动值
      },300);
    },

  

posted @ 2020-10-28 16:48  沁猿春  阅读(839)  评论(0)    收藏  举报