阻止小程序浮層點擊穿透和滑動穿透


  <view wx:if="{{selectMenu}}" catchtap="selectCancle" catchtouchmove='true' class="select-mask {{!!selectMenu?'select-in':'select-out'}}">
      <view class="select-menu">
        <view class="select-list">
          <scroll-view scroll-y="true" style="height: {{selectOptions.length > 5?'500rpx':selectOptions.length*100 + 'rpx'}};">
            <view wx:for="{{selectOptions}}" wx:key="index" data-id="{{item.id}}" data-name="{{item.name}}" catchtap="selectItem" class="select-item">{{item.name}}</view>
          </scroll-view>
        </view>
        <view catchtap="selectCancle" class="select-cancle">
          <text>取消</text>
        </view>
      </view>
    </view>

簡單小程序自身提供了相應的方法:

1.   catchtap:和bindtap相對應,catchtap有着阻止事件冒泡的作用;

2.   catchtouchmove:阻止浮層歡動穿透到頁面上,這里用到了scroll-view就順帶提一下,這是小程序組件視圖容器,表示可滾動視圖區域。


免責聲明!

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



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