报错复现
参考地址
https://github.com/ecomfe/echarts-for-weixin/pull/853
代码解决报错
再 echarts.vue 组件 修改如下
// echarts.vue 组件
touchStart(e) {
const { disableTouch, chart } = this;
if (disableTouch || !chart || !e.mp.touches.length) return;
const touch = e.mp.touches[0];
this.handler.dispatch('mousedown', {
zrX: touch.x,
zrY: touch.y,
//需要添加的方法即可解决报错
preventDefault: () => {},
stopImmediatePropagation: () => {},
stopPropagation: () => {}
});
this.handler.dispatch('mousemove', {
zrX: touch.x,
zrY: touch.y,
//需要添加的方法即可解决报错
preventDefault: () => {},
stopImmediatePropagation: () => {},
stopPropagation: () => {}
});
this.processGesture(wrapTouch(e), 'start');
},
touchMove(e) {
const {
disableTouch, throttleTouch, chart, lastMoveTime,
} = this;
if (disableTouch || !chart || !e.mp.touches.length) return;
if (throttleTouch) {
const currMoveTime = Date.now();
if (currMoveTime - lastMoveTime < 240) return;
this.lastMoveTime = currMoveTime;
}
const touch = e.mp.touches[0];
this.handler.dispatch('mousemove', {
zrX: touch.x,
zrY: touch.y,
//需要添加的方法即可解决报错
preventDefault: () => {},
stopImmediatePropagation: () => {},
stopPropagation: () => {}
});
this.processGesture(wrapTouch(e), 'change');
},
touchEnd(e) {
const { disableTouch, chart } = this;
if (disableTouch || !chart) return;
const touch = e.mp.changedTouches ? e.mp.changedTouches[0] : {};
this.handler.dispatch('mouseup', {
zrX: touch.x,
zrY: touch.y,
//需要添加的方法即可解决报错
preventDefault: () => {},
stopImmediatePropagation: () => {},
stopPropagation: () => {}
});
this.handler.dispatch('click', {
zrX: touch.x,
zrY: touch.y,
//需要添加的方法即可解决报错
preventDefault: () => {},
stopImmediatePropagation: () => {},
stopPropagation: () => {}
});
this.processGesture(wrapTouch(e), 'end');
},