首页 > 技术文章 > input ios键盘遮挡

zyt-it 2019-08-27 15:24 原文

直接放代码

 

// 获取焦点
focusInput() {
  let commentDom = document.querySelector('#textarea')
  setTimeout(function() {
    commentDom.scrollIntoView(true);
    commentDom.scrollIntoViewIfNeeded();
  }, 500)
},

在使用的input 或者textarea 需要被键盘顶起来,被顶起来的容器元素id为textarea

以上如果还不可以,在做第二步操作:给这个元素设置position:sticky

 

推荐阅读