小程序遮罩层上下滑动穿透 ---- 解决方法
2019-05-09 16:50
2416 查看
方法:最外层元素加上事件:catchtouchmove=“stopPageScroll”
遮罩层元素加上事件:catchtouchmove=“stopPageScroll”
遮罩层显示时 this.setData({ stopPageScroll:“stopPageScroll” })
遮罩层消失时 this.setData({ stopPageScroll:"" })
stopPageScroll(){ return }
WXML:
<view catchtouchmove='{{stopPageScroll}}'> <view wx:for="{{100}}" wx:key="key">{{index+1}}</view> </view> <view class='btn'> <text bindtap='maskShowfun'>显示</text> <text bindtap='maskHidefun'>隐藏</text> </view> <view class='mask' wx:if="{{maskShow}}" catchtouchmove='{{stopPageScroll}}'></view>
WXSS:
.mask{ width:100%; height:100%; top:0; background:rgba(0,0,0,0.5); overflow: hidden; position: fixed; z-index: 1; } .btn{ display: flex; font-size: 40rpx; position: fixed; bottom: 0; width: 100%; height: 100rpx; z-index: 99; } .btn text{ width:50%; height:100%; display:flex; align-items: center; justify-content:center; color:#fff; } .btn text:nth-child(1){ background: #ddd; } .btn text:nth-child(2){ background: red; }
JS:
Page({ data: { stopPageScroll:"", maskShow:false }, maskShowfun(){ this.setData({ stopPageScroll: "stopPageScroll", maskShow:true }) }, maskHidefun(){ this.setData({ stopPageScroll: "", maskShow: false }) }, stopPageScroll(){return} })
相关文章推荐
- SwipeMenuListView在ScrollView里上下滑动导致菜单不能显示完全的bug解决方法
- iOS 同一页面加载上百张图片,迅速滑动时导致内存暴涨程序崩溃的参考解决方法
- SwipeRefreshLayout与SwipeMenuListView上下左右滑动冲突解决方法
- slideview 侧滑时上下滚动 onitemclick和滑动的冲突 解决方法
- vue解决弹出蒙层滑动穿透问题的方法
- H5解决浏览器,微信背景的上下滑动问题,脱离窗口的js局部滚动解决方法
- 【C#】对异步请求处理程序IHttpAsyncHandler的理解和分享一个易用性封装 【手记】走近科学之为什么明明实现了IEnumerable<T>的类型却不能调用LINQ扩展方法 【手记】手机网页弹出层后屏蔽底层的滑动响应 【手记】ASP.NET提示“未能创建类型”处理 【Web】一个非常简单的移动web消息框 【手记】解决EXCEL跑SQL遇“查询无法运行或数据库表无法打开...”
- 解决SpringView与CoordinatorLayout和AppBarLayout嵌套使用的上下滑动冲突问题
- SQLServer2000安装程序提示“有一个挂起的安装实例,请重起机器”的解决方法
- Redis挖矿新程序wnTKYg解决方法
- 程序突然显示找不到UIImageView.h解决方法
- Dedecms自定义表单“数据校验不对,程序返回错误”的解决方法
- IntelliJ IDEA 编译程序出现 非法字符 的 解决方法
- MATLAB7.0程序打开后一会就自动关闭的解决方法
- 关于那个[老贼小软]封杀易语言程序的工作原理与解决方法
- Android上下TabHost设置及Did you forget to call 'public void setup(LocalActivityManager activityGroup)解决方法
- “以前的某个程序已在安装计算机上创建挂起的文件操作”的问题的解决方法...
- “另一个程序正在使用此文件,进程无法访问”的解决方法
- 解决oracle12c安装报“[INS-30131]执行安装程序验证所需的初始设置失败(原因:无法访问临时位置)”方法
- VS2005+ACCESS WEB程序出错数据访问权限错误的解决方法