【问题标题】:How to call methods in react-visjs-timeline如何在 react-visjs-timeline 中调用方法
【发布时间】:2018-08-24 19:26:26
【问题描述】:

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

方法如:

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

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

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

docs for react-visjs-timeline 没有提到如何调用方法。 ????

【问题讨论】:

    标签: javascript reactjs vis.js vis.js-timeline


    【解决方案1】:

    您只需调用 $el 的方法。

    this.timelineWrapperRef.current.$el.fit();
    this.timelineWrapperRef.current.$el.setItems({...});
    this.timelineWrapperRef.current.$el.focus(id);
    

    【讨论】:

    • 任何完整的例子,我试过了,但没有用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-15
    • 2017-02-27
    • 1970-01-01
    • 2019-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多