微信小程序滾動穿透問題


  做小程序項目遇到一個項目,就是點一個按鈕出現一個蒙層,然而下面的頁面還是可以滾動,解決如下:

  

<view bindtap="hideCoupon" class='coupon_receive_wrapper {{showCouponFlag==true?"active":""}}' catchtouchmove="preventD">
...
</view>

  樣式如下 :

.coupon_receive_wrapper{
  display:none;
  position:fixed;
  left:0;
  top:0;
  right:0;
  bottom:0;
  width:100%;
  height:100%;
  background:rgba(0,0,0,.5);
  z-index:11;
  transition: all 1s ease;
}
.coupon_receive_wrapper.active{
  display:block;
}

  給蒙層那個元素加個touchmove事件,這個事件用來阻止事件冒泡,preventD中的代碼如下:

  preventD(){}

  問題就解決了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM