微信小程序-自制弹出框禁止页面上下滑动

弹出 fixed 弹窗后,在弹窗上滑动会导致下层的页面一起跟着滚动。

解决方法:

在弹出层加上 catchtouchmove 事件

两种方法:(在电脑上测试是没有用的,这是触摸事件。因此,需要在手机端测试,预览生成一个开发版,用手机微信扫描即可看到效果)

1.

wxml:

<!-- 首页弹窗 -->
<view class='Popup' hidden='{{bool}}' catchtouchmove="test">
js:
  test:function(){
},
2.catchtouchmove="true"就行了,(个人感觉第二种方法比较简单,好用)
<!-- 首页弹窗 -->
<view class='Popup' hidden='{{bool}}' catchtouchmove="true">

 

posted @ 2018-09-06 15:04  新恒  阅读(6809)  评论(3编辑  收藏  举报