关于ios端微信input框键盘收起留白问题解决方案
方案一
document.body.addEventListener("focusout", () => {
setTimeout(() => {
const scrollHeight =
document.documentElement.scrollTop || document.body.scrollTop || 0;
window.scrollTo(0, Math.max(scrollHeight - 1, 0));
}, 100);
});
方案二
document.body.addEventListener('focusout', () => {
let ua = window.navigator.userAgent
if (!!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
let currentPosition, timer;
let speed = 1;
timer = setInterval(function () {
currentPosition = document.documentElement.scrollTop || document.body.scrollTop;
currentPosition -= speed;
window.scrollTo(0, currentPosition);
currentPosition += speed;
window.scrollTo(0, currentPosition);
clearInterval(timer);
}, 100);
}
})