Vue 弹出层时 禁止页面滑动

上代码

     /***滑动限制***/
      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,true);//页面可以滑动
      }

移动端弹出框时可以调用使用者两个方法,如果不是Vue,可以直接给html设置overflow:hinder


--------------------- 
作者:cdx1170776994 
来源:CSDN 
原文:https://blog.csdn.net/cdx1170776994/article/details/78775020 

猜你喜欢

转载自blog.csdn.net/u012302552/article/details/85125569
今日推荐