【问题标题】:React-big-calendar incorrect time displayReact-big-calendar 时间显示不正确
【发布时间】:2021-02-16 06:56:00
【问题描述】:

我正在尝试使用 React-big-calendar 显示事件。我的时间格式有问题。我在将事件传递给日历时使用的数据如下:

{
    end: Tue Nov 03 2020 21:42:16 GMT+0100 (Central European Standard Time)
    start: Tue Nov 03 2020 20:42:06 GMT+0100 (Central European Standard Time)
}

结果出乎意料。图书馆将我的时间格式视为 12 小时格式:

我还注意到日历中的current 时间值错误。我使用date-fns 作为带有波兰语locale 的定位器。我还在使用 culture 属性作为日历组件。这是我的组件 - https://github.com/sSwiergosz/fitness-platform/blob/develop/frontend/components/Calendar.js

我没有想法......有人可以帮助我吗?

【问题讨论】:

  • 不明白为什么这个问题被否决了......我正在根据文档做所有事情并提供完整的代码示例

标签: reactjs calendar react-big-calendar date-fns


【解决方案1】:

我没有完整的解决方案,但确定了关注的领域。更改了日历样式对象中的高度属性,并且未对齐发生了变化。因此,事件在时间轴上以不同比例呈现的方式似乎是一个问题。

【讨论】:

    【解决方案2】:

    你可以这样做:

    let formats = {
      timeGutterFormat: 'HH:mm',
    }
    
    export default function MyCalendar() {
      return (
         <Calendar
           localizer={localizer}
           formats={formats}
           ... 
    

    API 文档不完整,但仍有帮助:http://jquense.github.io/react-big-calendar/examples/index.html#api

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-16
      • 1970-01-01
      • 2022-06-29
      • 2018-05-22
      • 2021-10-03
      相关资源
      最近更新 更多