如何在 mozilla 上获取 fabric.js canvas 鼠标坐标

How to get fabric.js canvas mouse cordinates on mozzila

这是正在处理 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: event is undefined" 它指向 变量指针 = 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 );
});

'event' 必须定义为函数参数的一部分。请确保你有相同的逻辑。