代码:
弹框显示时调用:
let mo = function(e) {
e.preventDefault()
}
document.body.style.overflow = ''
document.removeEventListener('touchmove', mo, false)
弹框隐藏时调用:
let mo = function(e) {
e.preventDefault()
}
document.body.style.overflow = 'hidden'
document.removeEventListener('touchmove', mo, false)
我是通过watch监听显示隐藏的参数来调用此方法
watch: {
FormVisible() {
let mo = function(e) {
e.preventDefault()
}
if (!this.FormVisible) {
document.body.style.overflow = ''
document.removeEventListener('touchmove', mo, false)
}
if (this.FormVisible) {
document.body.style.overflow = 'hidden'
document.addEventListener('touchmove', mo, false)
}
}
}