【微信小程序】阻止遮罩层下的页面滚动

版权声明:本文为simorel原创文章,未经simorel允许不得转载。 https://blog.csdn.net/Simoral/article/details/84870449

参考博客,在此一并致谢:
1. AndrewNeo
2. 社会你强哥明天 的答案

解决方案

滑动scroll-view组件

在弹出层根元素上添加 catch:touchmove即可,<view catch:touchmove>...</view>

滑动scroll-view组件

在弹出层下的页面根元素添加动态样式class:

/* *.wxss */
.stop-scroll {
	position: fixed;
	top: 0;
	left: 0;
	height: 100%;
	width: 100%;
	overflow: hidden;
}
<!-- isShowPopup变量确认是否展示弹窗的变量 -->
<view class="{{ isShowPopup ? 'stop-scroll' : '' }}">
	<!-- ... -->
</view>

猜你喜欢

转载自blog.csdn.net/Simoral/article/details/84870449