美文网首页
2021-07-09 Vue 解决移动端滑动穿透问题

2021-07-09 Vue 解决移动端滑动穿透问题

作者: 本泽锅 | 来源:发表于2021-07-09 14:47 被阅读0次

当页面有弹窗时,并且这个弹窗有滚动事件时,这时候会遇到bug,最底部的内容区域会跟着滚动,导致弹窗滚动不生效,以下是解决方案:

//cityPop 控制弹窗的显示和隐藏
watch:{
            cityPop(val){
                if(val){
                    document.body.style.overflow = 'hidden'
                    document.addEventListener('touchmove', preD, {passive: false}) // 禁止页面滑动
                }else {
                    document.body.style.overflow = '' // 出现滚动条
                    document.removeEventListener('touchmove', preD, {passive: false})
                }
            }
        }

相关文章

网友评论

      本文标题:2021-07-09 Vue 解决移动端滑动穿透问题

      本文链接:https://www.haomeiwen.com/subject/fpefpltx.html