收藏
回答

小程序:防止点击遮罩层后遮罩层下面也反应的解决方法?

<view class="take1wx:if="{{isGouc}}"   bindtap='tapSeleBjcatchtouchmove="preventD">

                <view class="takeCatstyle="position:fixed;">

catchtouchmove="preventD"这种方法不管用啊

回答关注问题邀请回答
收藏

3 个回答

  • DDK
    DDK
    2023-08-08

    给蒙层标签添加一个catchtap事件响应,catchtap不同于bindtap的点是阻止下层向上冒泡,方法很笨,但很管用

    2023-08-08
    有用 1
    回复
  • 微盟
    微盟
    2021-08-22

    这就是事件穿透的问题。

    对于滑动事件,可以按照如下方法防止事件穿透。点击事件同理。

    // wxml
    <view class="mask" catchtouchmove="onTouchMove" />
    <view class="content" catchtouchmove="onTouchMove" >
      <slot/>
    </view>
    
    // js
    onTouchMove() {},
    
    2021-08-22
    有用
    回复
  • Jun
    Jun
    2020-04-10

    <view class="take1wx:if="{{isGouc}}"  mut-bind:tap="preventTouchMove">

                    <view class="takeCatmut-bind:tap="getstyle="{{isGouc?'position:fixed;':''}}">

    用了互拆还挺管用的

    2020-04-10
    有用
    回复 1
    • 皇儒
      皇儒
      2020-08-23
      能详细介绍下吗?也遇到这个问题了。
      2020-08-23
      回复
登录 后发表内容
问题标签