这是在 google chrome 上运行的代码
var pointer = canvas.getPointer(event.e);
var posiX = pointer.x;
var posiY = pointer.y;
posiX=Math.round( posiX );
posiY=Math.round( posiY );
在mozzila上,我收到“TypeError:事件未定义”,它指向 var 指针 = canvas.getPointer(event.e);
最佳答案
一毛钱,
请使用这样的鼠标事件:
canvas.on('mouse:down', function(event){
var pointer = canvas.getPointer(event.e);
var posiX = pointer.x;
var posiY = pointer.y;
posiX=Math.round( posiX );
posiY=Math.round( posiY );
});
“事件”必须定义为函数参数的一部分。请确保您具有相同的逻辑。
关于javascript - 如何在 mozilla 上获取 Fabric.js Canvas 鼠标坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41636200/