问题: canvas下,增加touch事件。 安卓下 touchstart ,touchmove ,touchend 。能全部监听到;但是在IOS测试下,执行到touchmove后就结束了,不会继续往下。
<canvas canvas-id="firstCanvas" :style="style" @click="canvasClick" @touchcancel="cancel" @touchstart="touchDouble" @touchend="stop" @touchmove="move" ></canvas>
stop(e) {
console.log("离开屏幕");
console.log(e);
this.isTouched = false;
},
move(e) {
e.preventDefault();
console.log("手指缩放事件");
console.log(e)
if (e.touches.length >= 2 && this.isTouched == true) {
this.end = e.touches;
if (this.getDistance(this.end[0], this.end[1]) < this.getDistance(this.start[0], this.start[1])) {
console.log("缩小");
} else {
console.log("放大")
}
}
},
touchDouble(e) {
e.preventDefault();
console.log("手指按下屏幕");
console.log(e);
console.log("屏幕touchu指纹:" + e.touches.length);
if (e.touches.length >= 2) {
this.start = e.touches;
this.isTouched = true;
}
},
安卓运行log、
IOS运行log