Fork me on Github

H5滑动穿透如何解决

https://github.com/pod4g/tool/wiki/%E7%A7%BB%E5%8A%A8%E7%AB%AF%E6%BB%9A%E5%8A%A8%E7%A9%BF%E9%80%8F%E9%97%AE%E9%A2%98

 

https://www.haorooms.com/post/webapp_bodyslidebcdiv

 

有几种方法:

一: 在出现遮罩层的时候 ,让遮罩的父元素
content{overflow:hidden}当遮罩层消失的时候移除这个属性

二: 这个是比较彻底的方法, 当弹窗出现的时候, 给body添加固定定位
body{
position:fixed;
top:0;left:0;right:0;bottom:0;
}

三: 使用JS在当前的遮罩元素上面注册以下事件

ele.addEventListener('touchstart',(e)=>{e.preventDefault()},false);
ele.addEventListener('touchmove',(e)=>{e.preventDefault()},false);

  

posted @ 2019-01-25 12:52  王者归来!  阅读(383)  评论(0编辑  收藏  举报