彈出 fixed 彈窗後,在彈窗上滑動會導緻下層的頁面一起跟着滾動。
解決方法:
在彈出層加上 catchtouchmove 事件
示例代碼:
<view class="modal-view" hidden="{{!showModal}}" bindtap="toggleModal" catchtouchmove="preventTouchMove">
<view class="modal">
<view class="modal-item" catchtap="makePhoneCall">{{site.phone}}</view>
<view class="modal-item" catchtap="toggleModal">取消</view>
</view>
</view>
Pages({
preventTouchMove() {}
})
在電腦上測試是沒有用的,這是觸摸事件。是以,需要在手機端測試,預覽生成一個開發版,用手機微信掃描即可看到效果。
還有一種方法如下:給catchtouchmove="ture"
<view class="modal-view" hidden="{{!showModal}}" bindtap="toggleModal" catchtouchmove="ture">
<view class="modal">
<view class="modal-item" catchtap="makePhoneCall">{{site.phone}}</view>
<view class="modal-item" catchtap="toggleModal">取消</view>
</view>
</view>