【问题标题】:Get starting and ending date of react calendar获取反应日历的开始和结束日期
【发布时间】:2019-02-18 12:04:44
【问题描述】:

我正在使用"react-big-calendar": "^0.20.3",

目前我在组件上使用getDrilldownView={(targetDate, currentViewName, configuredViewNames) => this.updateDate(targetDate, currentViewName, configuredViewNames)}props 来获取大日历反应 js 中的开始和结束时间。我觉得这不是获取开始和结束日期的好方法,我也无法在文档中找到它。

https://codesandbox.io/s/vw3wlm63y

我想要的是 2019/1/27 作为开始日期和 2019/3/2 作为结束日期

onRangeChange 在视图或日期更改时提供开始和结束日期,但我希望在页面加载时提供

【问题讨论】:

    标签: reactjs calendar react-big-calendar


    【解决方案1】:

    我正在使用

    this.startDate = moment().subtract(1, 'months').endOf('month').startOf('week').format('YYYY/MM/DD');
            this.endDate = moment().add(1, 'months').startOf('month').endOf('week').format('YYYY/MM/DD');
    

    并且成功了 获取第一次加载当前日历视图的开始和结束日期。我认为没有内置方法可以获取详细信息。

    【讨论】:

      【解决方案2】:

      我在 react-big-calendar 遇到了同样的问题,我解决了:

      const start = moment().startOf('month').startOf('week').format('YYYY/MM/DD');
      const end = moment().endOf('month').endOf('week').format('YYYY/MM/DD');
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多