事件的可见网络类型绑定

问题描述

可见网络事件是否有任何TS类型?

我已检查https://github.com/visjs/vis-network/blob/master/types/network/Network.d.ts,并且事件有效负载的类型为任何

  /**
   * Set an event listener.
   * Depending on the type of event you get different parameters for the callback function.
   *
   * @param eventName the name of the event,f.e. 'click'
   * @param callback the callback function that will be raised
   */
  on(eventName: NetworkEvents,callback: (params?: any) => void): void;

鉴于我已经介绍了以下数据结构:

export interface IClickEvent {
  pointer: {
    DOM: ICoordinates;
    canvas: ICoordinates;
  }
  nodes: INode[];
  edges: IEdge[];
}

export interface INode {
  id: number;
}

export interface IEdge {
  id: string;
}

export interface ICoordinates {
  x: number,y: number
}

所以我可以这样使用它:

  ngAfterViewInit(): void {
    ...
    this.networkInstance.addEventListener('click',this.handleClick);
    ...
  }

  handleClick(event: IClickEvent): void {
    console.log(JSON.stringify(event.pointer));
    console.log(JSON.stringify(event.nodes));
    console.log(JSON.stringify(event.edges));
  }

这种正确用法或可视网络是否已经具有事件的类型定义?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)