【问题标题】:react-datetime + set interval in Reactreact-datetime + 在 React 中设置时间间隔
【发布时间】:2017-12-03 02:03:29
【问题描述】:

我正在为 npm 包使用 react-datetime 控件:click here。 在那个时间选择器中,我应该如何设置间隔。例如,我想每 5 分钟设置一次间隔,所以先显示 0,然后显示 5、10、15 等。我怎样才能做到这一点?

我正在使用看起来像这样但不工作:

【问题讨论】:

  • 寻找timeConstraints设置属性
  • 是的。表示时间选择器设置特定间隔

标签: reactjs datetime npm react-datetime


【解决方案1】:

timeConstraints 允许自定义步骤配置,因此,它应该如下所示:

  minutes: { step: 5 }

示例:

{
  timeConstraints = {
    minutes: {
      step: 5
    }
  }

  render() {

    return (
      <Datetime timeConstraints={this.timeConstraints} />
    );
  }
}

【讨论】:

  • 直接添加:timeConstraints = {{ minutes: { step: 15 }}}
猜你喜欢
  • 2018-08-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-01
  • 1970-01-01
  • 2020-06-21
  • 1970-01-01
  • 2021-03-03
  • 1970-01-01
相关资源
最近更新 更多