创建组件时禁止页面滚动:
created(){ //禁止页面滑动 document.body.addEventListener('touchmove', this.bodyScroll, { passive: false }); },
组件销毁时解除禁止:
destroyed(){ // 解绑禁止页面滚动事件 document.body.removeEventListener('touchmove', this.bodyScroll, { passive: false }); }
bodyScroll方法:
bodyScroll(event){ event.preventDefault(); }