h5页面 ios去除上下回弹效果

ios的上下回弹效果,确实提高了用户体验,但有时我们的业务场景不需要这个回弹效果,控制代码如下

document.body.addEventListener('touchmove', function (e) {
    e.preventDefault(); //阻止默认的处理方式(阻止下拉滑动的效果)
  }, {passive: false}); //passive 参数不能省略,用来兼容ios和android

2015年底,DOM 规范做了修订:addEventListener() 的第三个参数可为 {} 对象

el.addEventListener(type, listener, {
 capture: false, //  useCapture 冒泡
 once: false, // false:非单次监听
 passive: false // 当属性passive的值为true的时候,代表该监听器内部不会调用preventDefault函数来阻止默认滑动行为;false就调用preventDefault函数
})
原文地址:https://www.cnblogs.com/HYZhou2018/p/12313117.html