Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue3中使用事件event.stopPropagation()无法阻止touchmove事件冒泡,但是如果给事件绑定的地方加上.stop事件修饰符却可以阻止冒泡 #4972

Open
Bulandent opened this issue Jun 7, 2024 · 1 comment
Labels
question Further information is requested vue3

Comments

@Bulandent
Copy link

以下代码使用 stop 事件修饰符能阻止事件冒泡,使得 swiper 无法滚动。

<!-- 只贴了关键代码 -->
<swiper>
      <swiper-item @touchmove.stop="touchSwiper">1</swiper-item>
...

const touchSwiper = () => {}

但是我想动态的控制 swiper 的滚动,所以不能用 .stop 修饰符,使用了stopPropagation() 如下代码所示,但是这样却没有效果。

<swiper>
      <swiper-item @touchmove="touchSwiper">1</swiper-item>
...

const touchSwiper = e => {
    if (!canSwiper) {
         e.stopPropagation()
    }
}

应该如何做才能动态控制事件冒泡?uni-app 对 stop 修饰符有没有做什么特殊处理?

@Otto-J Otto-J added question Further information is requested vue3 labels Jun 7, 2024
@zzxqd
Copy link

zzxqd commented Jun 26, 2024

跟这个问题应该是一样的
#2191

要不通过v-if 要不就通过css的pointer-events: none;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested vue3
Projects
None yet
Development

No branches or pull requests

3 participants