三个事件
<view
@touchmove="handletouchmove($event)"
@touchstart="handletouchstart"
@touchend="handletouchend"
>
用法
handletouchmove(event) {
// 左右切换为 X 即可
let currentY = event.changedTouches[0].pageY;
let ty = currentY - this.lastY;
if (ty < -20) {
// 向上滑动
} else if (ty > 20) {
//向下滑动
}
//将当前坐标进行保存以进行下一次计算
this.lastY = currentY;
},
handletouchstart(event) {
//滑动开始
this.lastY = event.changedTouches[0].pageY;
},
handletouchend(event) {
//停止滑动
},