<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就顺带提一下,这是小程序组件视图容器,表示可滚动视图区域。