小程序弹窗禁止页面滚动


弹出 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>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM