web-interview
web-interview copied to clipboard
[vue] 36. vue 弹窗后如何禁止滚动条滚动?
methods : { //禁止滚动 stop(){ var mo=function(e){e.preventDefault();}; document.body.style.overflow='hidden'; document.addEventListener("touchmove",mo,false);//禁止页面滑动 }, /取消滑动限制/ move(){ var mo=function(e){e.preventDefault();}; document.body.style.overflow='';//出现滚动条 document.removeEventListener("touchmove",mo,false); } }
https://github.com/willmcpo/body-scroll-lock