如何阻止h5body的滑动

做了个选择时间的控件。处于上一层,滑动选择时间的时候,有时候底部也跟着滑动。该怎么解决呢?

阅读 4.1k
1 个回答
// 禁止
document.body.style.overflow = 'hidden';
function _preventDefault(e) { e.preventDefault(); }
window.addEventListener('touchmove', _preventDefault);

// 恢复
document.body.style.overflow = 'auto';
window.removeEventListener('touchmove', _preventDefault);
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题