做小程序項目遇到一個項目,就是點一個按鈕出現(xiàn)一個蒙層,然而下面的頁面還是可以滾動,解決如下: view bindtap="hideCoupon" class='coupon_receive_wrapper {{showCouponFlag==true?"active":""}}' catchtouchmov ...
<view bindtap="hideCoupon" class='coupon_receive_wrapper {{showCouponFlag==true?"active":""}}' catchtouchmove="preventD">
樣式如下 :
.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(){}問題就解決了。