vue 长按 离开屏幕 事件

vue长按事件touch

2018年02月02日 17:16:09

阅读数:3621

1.touch事件

以下是四种touch事件

touchstart:     //手指放到屏幕上时触发

touchmove:      //手指在屏幕上滑动式触发

touchend:    //手指离开屏幕时触发

touchcancel:     //系统取消touch事件的时候触发,这个好像比较少用

2.长按弹出删除按钮,点击删除

<div v-for="item in list" @touchstart.native="showDeleteButton(item.id)" @touchend.native="clearLoop(item.id)">
	内容...
</div>
showDeleteButton(e) {
	clearInterval(this.Loop); //再次清空定时器,防止重复注册定时器
	this.Loop = setTimeout(function() {
		this.$dialog.confirm({   //这是个弹出框,用的ydui
			title: '温馨提示',
			mes: '是否删除此条消息',
			opts: () => {
				this.$dialog.loading.open('删除中...');
				this.$http.post(this.$store.state.ip + '...', {
					id: e
				}, {
				    headers: {},
				}).then((response) => {
					this.$dialog.loading.close();
						this.$dialog.toast({
							mes: response.body.info,
							timeout: 1000
						});
						var data = this.rulist
						console.log(data)
						for(var i in data) {
							if(data[i].id == e) {
								data.splice(i, 1)
							}
						}
						console.log(data)
						this.rulist=data
						}).catch(function(response) {
 
						});
					}
		});
	}.bind(this), 1000);
},
clearLoop(e) {
	clearInterval(this.Loop);
},
 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值