关于处理小程序弹窗滚动穿透的心得
发布于 1 年前 作者 yang55 2738 次浏览 来自 分享

在开发小程序时,经常会使用到弹窗(遮罩层+弹窗内容),这时滑动弹窗页面,底层的页面会发生滚动。

个人处理方法(微信开发工具不报错):

逻辑:

1、在遮罩层最外层元素标签中绑定touchmove事件:@touchmove=“xxxx”; 和 catchtouchmove 属性(catchtouchmove是捕获touchmove事件的

2、在methods里定义该方法,方法返回true :return true

代码:

<template>

&lt;view catchtouchmove [@touchmove](/user/touchmove)="mask"&gt;

	遮罩层内容

&lt;/view&gt;

</template>

<script>

data()&nbsp;{

},

methods:{

mask(){

		return true

},

}

</script>

回到顶部