直接贴出解决方案,需要在vue文件里面拷贝f2-canvas.js里面的代码:
F2.Util.addEventListener = function (source, type, listener) {
source.addListener(type, listener);
};
F2.Util.removeEventListener = function (source, type, listener) {
source.removeListener(type, listener);
};
F2.Util.createEvent = function (event, chart) {
const type = event.type;
let x = 0;
let y = 0;
const touches = event.touches;
if (touches && touches.length > 0) {
x = touches[0].x;
y = touches[0].y;
}
return {
type,
chart,
x,
y
};
};
放到引入f2.js文件代码的下面,就解决了。
本文提供了一种解决F2 Canvas事件监听问题的方法,通过在Vue项目中直接修改F2库源码实现对事件的监听与取消监听。具体操作包括重写F2库中的事件添加与移除函数。
799

被折叠的 条评论
为什么被折叠?



