Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
749 views
in Technique[技术] by (71.8m points)

有一些手机机型,软键盘弹出时,页面无法被顶起,这种情况怎么处理?

目前出现在oppo和三星手机


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
//scrollIntoViewIfNeeded、scrollIntoView 需要考虑兼容性。

const ua = window.navigator.userAgent.toLocaleLowerCase();
const isAndroid = /android/.test(ua);
if (isAndroid) {
    setTimeout(() => {
      this.$refs.inputRef.scrollIntoViewIfNeeded();
    }, 0);
}

or

// 安卓下键盘弹出会触发window.resize事件,document.body.clientHeight会改变

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...