在有弹出框的页面中,弹出框出现时调用禁止滚动方法stopScroll()。
//禁止滚动
stopScroll(){
var mo=function(e){e.preventDefault();};
document.body.style.overflow='hidden';
document.addEventListener("touchmove",mo,false);//禁止页面滑动
}
弹出框取消时调取允许滚动方法canScroll()即可恢复滚动。
/***允许滚动***/
canScroll(){
var mo=function(e){e.preventDefault();};
document.body.style.overflow='';//出现滚动条
document.removeEventListener("touchmove",mo,false);
}
文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/114740.html<