微信小程序向左向右滑动事件

<view  bindtouchstart="touchstart" bindtouchend="touchend">向左向左向左,向右滑动啦啦啦view>
Page({
	data: {
		nowclientX: ""
	},
	touchstart(e) {
		console.log(e)
		this.setData({
			nowclientX: e.changedTouches[0].clientX
		})
	},
	touchend(e) {
		let nowclientX = this.data.nowclientX;
		let clientX = e.changedTouches[0].clientX;
		if (clientX > nowclientX) {
			console.log("向右滑动")
		} else {
			console.log("向左滑动")
		}
	}
})

你可能感兴趣的:(微信小程序,前端)