正如标题所解释的,我正在尝试通过事件处理程序将数据发送到函数。
我试过以下方法:
canvas.on("mouse:wheel",{name:"spin"}, constructSpin);
function constructSpin(e){
console.log(e.data.name);
}
遗憾的是这不起作用:(
有什么方法可以使用事件处理程序将数据发送到函数吗?
注意:我在 fabric 文档中找到了这个:
on(eventName, handler) → {Self}
所以看起来没有数据在 build 中!
最佳答案
如果您希望在 mouse:wheel
事件上传递一些自定义数据,您应该按以下方式构造和调用 constructSpin
函数:
canvas.on("mouse:wheel", function(e) {
constructSpin(e, { name: "spin" });
});
function constructSpin(event, data) {
console.log(data.name);
}
关于javascript - 在 fabric js 中使用事件处理程序 (.on) 将数据发送到函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45907866/