9

使用react-visjs-timeline,如何调用 Timeline 组件的方法?

方法如:

  • timeline.fit();
  • timeline.setItems({...});
  • timeline.focus(id);

我向组件添加了一个引用,但我不确定要在哪个项目上调用方法:

<Timeline
  ref={this.timelineWrapperRef}
  options={this.state.options}
  items={this.state.items}
/>

文档react-visjs-timeline没有提到如何调用方法。

4

1 回答 1

9

您只想从$el.

this.timelineWrapperRef.current.$el.fit();
this.timelineWrapperRef.current.$el.setItems({...});
this.timelineWrapperRef.current.$el.focus(id);
于 2018-08-24T19:28:15.133 回答