創建組件時禁止頁面滾動:
created(){ //禁止頁面滑動 document.body.addEventListener('touchmove', this.bodyScroll, { passive: false }); },
組件銷毀時解除禁止:
destroyed(){ // 解綁禁止頁面滾動事件 document.body.removeEventListener('touchmove', this.bodyScroll, { passive: false }); }
bodyScroll方法:
bodyScroll(event){ event.preventDefault(); }