如题:代码如下
//touchStart事件
p.ontouchstart=function(event) {
var touch = event.targetTouches[0];
startY = touch.pageY;
console.log(startY);
};
//touchmove事件
p.ontouchmove=function(event) {
var touch = event.targetTouches[0];
endY = touch.pageY;
var Y = endY - startY;
if(Y > 0) {
alert("向下");
} else if(Y < 0) {
alert("向上");
}
}```
找到答案了:类似BUG
我的方法是直接绑到html上的(因为是要监听整个页面,所以就直接绑定到html节点上了,真没想到还有这个坑),没办法,所谓的受气的小媳妇就是我们这样的,踩了设备的坑,只能咽下。只能用一个盒子,铺满页面,然后把方法绑定到它头上了