思路:
1)调用js的touch的API接口分别监听touchstart,touchmove,touchend事件
2)使用计时器可以设定时间用于区分长按和点击
<template>
<div class="about">
<p @touchstart="start" @touchmove="move" @touchend="end">
this is a picture
</p>
</div>
</template>
<script>
export default {
data() {
return {
longClick: 0,
timeOutEvent: 0
};
},
methods: {
start() {
var that = this;
this.longClick = 0;
this.timeOutEvent = setTimeout(function() {
that.longClick = 1;
console.log("这是长按")
}, 500);
},
move(e) {
clearTimeout(this.timeOutEvent);
this.timeOutEvent = 0;
e.preventDefault();
console.log("这是滑动")
},
end() {
clearTimeout(this.timeOutEvent);
if (this.timeOutEvent != 0 && this.longClick == 0) {
//点击
//此处为点击事件----在此处添加跳转详情页
console.log("这是点击");
}
return false;
}
}
};
</script>
版权声明:本文为weixin_36185028原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。