在移动端中,部分安卓手机遇到输入框被软键盘遮挡问题。
解决方法:
//如果是安卓手机,添加获得焦点的滚动事件
if (/Android/gi.test(navigator.userAgent)){
window.addEventListener('resize', function() {
if (document.activeElement.tagName == 'INPUT'|| document.activeElement.tagName == 'TEXTAREA') {
window.setTimeout(function() {
document.activeElement.scrollIntoViewIfNeeded();
}, 0);
}
});
}