ios12系统键盘回收后会留下一个透明的遮罩层,在点击页面底部,点击事件没法穿透遮罩层,相当于事件被拦截了。
项目用的vue开发的,处理思路:在input失去焦点后,页面上下滚动1px,去除遮罩层;该方法作用所有input需要在input用@blur=iosBlur引入
iosBlur() {
let ua = window.navigator.userAgent;
if (!!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
//ios系统
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);
// alert("失去焦点")
}, 100);
}
},
加入组件密码框 页面回到顶部