konva 2D 绘图 - 我可以在鼠标按下事件中发送另一个变量吗?

konva 2D drawing - can i send another variable in mouse down event?

我想在鼠标事件中发送另一个值,因为我的 handleMouseDown 函数在另一个文件中。

stage.on('mousedown', handleMouseDown(evt, stage))

但我收到错误:

- Argument of type 'void' is not assignable to parameter of type 'KonvaEventListener<Stage, MouseEvent>'.ts(2345)
- Cannot find name 'evt'.ts(2304)

我尝试从 init 文件导出我的阶段,然后导入另一个文件,但我无法从导出默认值导出值

import { handleMouseDown } from './stageEvents'
export default (): void => {
  export const stage: Stage = new Konva.Stage({
    container: 'container',
    height: 500,
    width: 500
  })
  // bind stage event
  stage.on('mousedown', handleMouseDown)

错误:修饰符不能出现在这里

请问有人有什么想法吗?

您可能想要这样做:

stage.on('mousedown', (evt) => handleMouseDown(evt, stage));