Fullcalendar - 如何在周视图中添加一天中的时间

Fullcalendar - How to add time of the day in week view

默认周视图是这样的,左侧没有时间:

http://fullcalendar.io/views/basicWeek/

但我想以这种方式显示视图,将一天中的时间显示在左侧:

http://fullcalendar.io/js/fullcalendar-2.3.1/demos/agenda-views.html

单击上方按钮面板上的 'week' 可以看到它。

如何配置它以使其看起来像这样?

谢谢!

您想使用 defaultView 属性。此设置,如指定 in the docs, the initial view when the calendar loads. The specific view you want is agendaWeek (list of available views).

因此,当您初始化日历时,您将放置 defaultView: 'agendaWeek'

示例:

$('#fullCal').fullCalendar({
  events: [{
    title: 'Random Event 1',
    start: moment().add(-4, 'h'),
    end: moment().add(-2, 'h'),
    allDay: false
  }, {
    title: 'Random Event 2',
    start: moment().add(1, 'h'),
    end: moment().add(2, 'h'),
    allDay: false
  }, {
    title: 'Random Event 3',
    start: moment().add(6, 'h'),
    end: moment().add(8, 'h'),
    allDay: false
  }],
  header: {
    left: '',
    center: 'prev title next today',
    right: ''
  },
  timezone: 'local',
  defaultView: 'agendaWeek' /* this is the line you need */
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.1.1/fullcalendar.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.1.1/fullcalendar.min.js"></script>

<div id="fullCal"></div>