【问题标题】:change current day in full calendar day view在完整日历日视图中更改当前日期
【发布时间】:2019-09-30 06:11:19
【问题描述】:

我想更改视图日期,例如如果我选择 25/12/2019,那么它应该显示 2019 年 12 月 25 日作为标题。我怎样才能做到这一点?

仅供参考:我正在使用 react Full-calendar 插件

<FullCalendar
  defaultView="timeGridDay"
  header={{
    left: "prev,next today",
    center: "title"
  }}
  plugins={[dayGridPlugin, timeGridPlugin, interactionPlugin]}
  weekends={this.state.calendarWeekends}
  events={this.state.calendarEvents}
  dateClick={this.handleDateClick}
/>

【问题讨论】:

    标签: javascript reactjs fullcalendar fullcalendar-4


    【解决方案1】:

    使用titleFormat

    使用 moment 插件

    import momentPlugin from '@fullcalendar/moment';
    
    <FullCalendar
      defaultView="timeGridDay"
      header={{
        left: "prev,next today",
        center: "title"
      }}
      plugins={[dayGridPlugin, timeGridPlugin, interactionPlugin]}
      weekends={this.state.calendarWeekends}
      events={this.state.calendarEvents}
      dateClick={this.handleDateClick}
      titleFormat='MMMM D, YYYY'
    />
    

    【讨论】:

    • 这产生了一个错误,没有得到正确的输出。
    • @HarshPatel 我已经更新了我的编码。请检查是否有任何问题让我知道。
    • 是的,和我做的一样,{ month: 8, year: 2019, day: 1 } 但由于某些插件错误而无法正常工作
    • 更可能的对象(来自您的原始版本)应该只是有一个额外的括号 - 就像“标题”选项一样。例如。 titleFormat={{ month: 'long', year: 'numeric', day: 'numeric' }}。这似乎是特定于 Angular 插件的语法
    • 附言。 @HarshPatel 如果您遇到错误,您应该提及它所说的内容,以防我们可以修复它。说有“一些错误”并不能让人帮你解决它
    猜你喜欢
    • 2015-06-15
    • 2014-07-23
    • 2011-08-03
    • 1970-01-01
    • 2022-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-15
    相关资源
    最近更新 更多