叶耳朵
叶耳朵
  • 发布:2020-04-21 16:41
  • 更新:2022-10-28 10:55
  • 阅读:10885

uni-app自定义长按事件

分类:uni-app

<view   @touchmove="handletouchmove" @touchstart="handletouchstart" @touchend="handletouchend" >  
</view>  

             handletouchstart(e) {  
                this.timeOutEvent = setTimeout(() => {  
                    this.onLongPress(e)  
                }, 1000); //这里设置定时器,定义长按1000毫秒触发长按事件,时间可以自己改,  
                return false;  
            },  
            handletouchend() {  
                clearTimeout(this.time); //清除定时器    
                if (this.time != 0) {  
                    //处理点击时间  
                }  
                return false;  
            },  
            handletouchmove() {  
                clearTimeout(this.time); //清除定时器    
                this.time = 0;  
            },  
           onLongPress(e) {  
                    // 处理长按事件  
           }  
1 关注 分享
Kytrun

要回复文章请先登录注册

就这样吧001

就这样吧001

我擦 这评价我就不尝试这种写法了。。。
2022-10-28 10:55
1***@qq.com

1***@qq.com

垃圾玩意
2021-10-20 11:57
cur

cur

垃圾玩意
2021-05-13 23:06
菩提下笑看浮生

菩提下笑看浮生

垃圾
2021-05-12 10:25