使用react-visjs-timeline
,如何调用时间轴组件的方法?
方法如下:
timeline.fit();
timeline.setItems({...});
timeline.focus(id);
我向组件添加了一个 ref,但我不确定要调用哪个项目的方法:
<Timeline
ref={this.timelineWrapperRef}
options={this.state.options}
items={this.state.items}
/>
react-visjs-timeline
的文档没有提到如何调用方法。 😕
你只需要从$el
中调用这些方法。
this.timelineWrapperRef.current.$el.fit();
this.timelineWrapperRef.current.$el.setItems({...});
this.timelineWrapperRef.current.$el.focus(id);