vant dropDownMenu/popup 组件滑动穿透问题

255 阅读1分钟

思路:指定给页面加类名,监听下拉框开关事件

参考文章:www.jianshu.com/p/25900a635… 介绍: 注意要在页面第一个元素 zh.uniapp.dcloud.io/component/p…

// 以下vant-weapp不可用 不能用watch 思路:popup弹出时,组织部body元素默认的滚动行为 具体代码:



//dropdown-item.vue实例内
 <van-popup :show="showPopup" >
 methods:{
      handler(e) {e.preventDefault()},
       
 }
      
watch: {
    popupVisible: function (val) {
      if(val) {
          document.getElementsByTagName('body')[0].addEventListener('touchmove', this.handler, { passive: false });
      } else {
          document.getElementsByTagName('body')[0].removeEventListener('touchmove', this.handler, { passive: false });
      }
    }
}

参考资料: blog.csdn.net/u012374026/…

blog.csdn.net/qq_40409143…