微信小程序开发过程中bindtap事件与bindtouchstart和bindtouchend事件冲突

查看:4295
本文介绍了微信小程序开发过程中bindtap事件与bindtouchstart和bindtouchend事件冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

<view class="container" catchtouchstart="handleTouchStart" catchtouchend="handleTouchEnd">
    <scroll-view scroll-y class="wrapper">
        <view class="list-item" wx:for="{{list}}" wx:key="{{item.id}}" data-id="{{item.id}}" catchtap="handletap">
            <image class="image" src="{{item.img}}"></image>
            <view class="right">
                <text class="title">{{item.title}}</text>
                <text class="intro">{{item.intro}}</text>
                <text class="time">{{item.time.date}}</text>
            </view>
        </view>
    </scroll-view>
</view>

代码如上,当点击.list-item时并没有触发bindtap事件,而是触发了catchtouchstart,catchtouchend

把catchtouchstart,catchtouchend事件移除后,能正常捕捉bindtap

请问有什么好的方法解决,catchtouchstart,catchtouchend事件不能移除,另有他用。

解决方案

tap,touchstart,touchend的事件触发顺序为start→end→tap
所以问题在于catchtouchstart,catchtouchend后事件被阻止了,tap捕获不到。
改为bindtouchstart,bindtouchend后问题得以解决。

这篇关于微信小程序开发过程中bindtap事件与bindtouchstart和bindtouchend事件冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆