阻止小程序浮层点击穿透和滑动穿透


  <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