Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
typescript中的JointJS事件处理程序_Typescript_Jointjs - Fatal编程技术网

typescript中的JointJS事件处理程序

typescript中的JointJS事件处理程序,typescript,jointjs,Typescript,Jointjs,我正在尝试在typescript中为jointjs文件添加事件处理程序,但没有找到一种使用jointjs定义文件实现它的方法 private paper = new joint.dia.Paper({ el: $('#paper'), width: 650, height: 400, gridSize: 20, model: this.graph, markAvailable:

我正在尝试在typescript中为jointjs文件添加事件处理程序,但没有找到一种使用jointjs定义文件实现它的方法

private paper = new joint.dia.Paper({
          el: $('#paper'),
          width: 650,
          height: 400,
          gridSize: 20,
          model: this.graph,
          markAvailable: true,
          linkConnectionPoint: joint.util.shapePerimeterConnectionPoint,
          snapLinks: true
     });

   this.paper.on('mouseclick', () => {
      console.log('Congratulations, you clicked the mouse!');
   });
获取错误消息

TS1068:意外令牌。应为构造函数、方法、访问器或属性


如何使用typescript为rect和line添加事件处理程序?

JointJS非常依赖于其他库,例如jQuery和主干。在这种情况下,paper.mouseclick函数允许您根据joint.d.ts定义文件传递事件:

mouseclickevt:Event:void; 以事件作为参数调用此函数将触发该事件。但是,我假设您实际上对处理事件而不是触发事件更感兴趣。在本例中,Paper类扩展了一个主干。在视图中可以按如下方式对其进行操作:

let paper=新接缝直径纸; 纸张。在“鼠标点击”上,=>{ log“恭喜你,你点击了鼠标!”; }; 希望这就是你要找的。

这对我有用

   paper.on('cell:pointerup', () => {
      console.log('Congratulations, you clicked the mouse!');
  });

我有一个为我工作:

paper.on('blank:pointerclick', function(evt, x, y) {

  //do whatever

}); //end paper.on

谢谢你的关心,我已经尝试了你的代码,但我得到了新的错误,我已经更新了问题