// 虚拟键盘遮挡输入框的解决方案
(function (doc) {
var docEl = doc.documentElement;
docEl.addEventListener('touchstart', function (e) {
let target = e.target;
if (target.tagName.toLowerCase() === 'input') {
var reg = /^(number|text|password)$/
if (reg.test(target.type)) {
setTimeout(function () {
if (target.scrollIntoViewIfNeeded) {
//alignCenter
target.scrollIntoViewIfNeeded(true);
} else {
//alignWithTop
target.scrollIntoView && target.scrollIntoView(false);
}
}, 50);
}
}
}, false)
})(document);
虚拟键盘遮挡输入框的解决方案
最新推荐文章于 2022-08-25 23:58:18 发布