<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就順帶提一下,這是小程序組件視圖容器,表示可滾動視圖區域。
