在main.js中设置全局函数:
//弹出框禁止滑动 Vue.prototype.noScroll = function () { var mo = function (e) { e.preventDefault() } document.body.style.overflow = 'hidden' document.addEventListener('touchmove', mo, false)// 禁止页面滑动 }
//弹出框可以滑动 Vue.prototype.canScroll = function () { var mo = function (e) { e.preventDefault() } document.body.style.overflow = ''// 出现滚动条 document.removeEventListener('touchmove', mo, false) } 在页面使用时:
//禁止主页面滑动 this.noScroll()
//主页面可滑动 this.canScroll()