Javascript 为什么资源没有显示在FullCalendar中

Javascript 为什么资源没有显示在FullCalendar中,javascript,fullcalendar,fullcalendar-4,Javascript,Fullcalendar,Fullcalendar 4,我有上面的FullCalendar脚本可以工作,但我想显示资源(房间),我需要更改什么才能做到这一点 document.addEventListener('DOMContentLoaded', function() { var calendarEl = document.getElementById('calendar'); var calendar = new FullCalendar.Calendar(calendarEl, { plugins: [ 'interaction',

我有上面的FullCalendar脚本可以工作,但我想显示资源(房间),我需要更改什么才能做到这一点

  document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');

var calendar = new FullCalendar.Calendar(calendarEl, {
  plugins: [ 'interaction', 'dayGrid', 'timeGrid', 'list', 'resourceTimeline' ],
  now: '2019-08-07',
  editable: false, // enable draggable events
  aspectRatio: 1.8,
  scrollTime: '00:00', // undo default 6am scrollTime
  header: {
    left: 'today prev,next',
    center: 'title',
    right: 'month,timeline3Months'
  },
 defaultView: 'timeline3Months',
  views: {
    timeline3Months: {
      type: 'timelineMonth',
      slotDuration: { days: 1 },
      duration: { months: 3 }
   }
 },
buttonText: {
  month: '1 Month',
  timeline3Months: '3 Months',
},     
  resourceLabelText: 'Rooms',
  resources: [
    { id: 'a', title: 'Auditorium A' },
    { id: 'b', title: 'Auditorium B', eventColor: 'green' },
    { id: 'c', title: 'Auditorium C', eventColor: 'orange' },
    { id: 'd', title: 'Auditorium D', children: [
      { id: 'd1', title: 'Room D1' },
      { id: 'd2', title: 'Room D2' }
    ] },
    { id: 'e', title: 'Auditorium E' },
    { id: 'f', title: 'Auditorium F', eventColor: 'red' },
    { id: 'z', title: 'Auditorium Z' }
  ],
  events: [
    { id: '1', resourceId: 'b', start: '2019-08-07T02:00:00', end: '2019-08-07T07:00:00', title: 'event 1', description: 'description for Repeating Event' },
    { id: '2', resourceId: 'c', start: '2019-08-07T05:00:00', end: '2019-08-07T22:00:00', title: 'event 2', description: 'description for Repeating Event' },
    { id: '3', resourceId: 'd', start: '2019-08-06', end: '2019-08-08', title: 'event 3', description: 'description for Repeating Event' },
    { id: '4', resourceId: 'e', start: '2019-08-07T03:00:00', end: '2019-08-07T08:00:00', title: 'event 4', description: 'description for Repeating Event' },
    { id: '5', resourceId: 'f', start: '2019-08-07T00:30:00', end: '2019-08-07T02:30:00', title: 'event 5', description: 'description for Repeating Event' }
  ]



});
calendar.render();
}))

我想显示日历,如图所示。。

时间线和资源时间线视图不是一回事。简单的“时间线”视图不使用或不需要资源,它只是以时间线样式显示非资源感知事件。这是有案可查的

要在时间线上显示资源,您需要将视图类型指定为“resourceTimeline”,而不仅仅是“timeline”。(您还指定了“timelineMonth”,这毫无意义,因为您试图创建3个月的持续时间,而“Month”指定了一个月。)

因此,自定义视图定义应如下所示:

timeline3Months: {
    type: "resourceTimeline",
    slotDuration: { days: 1 },
    duration: { months: 3 }
}
演示:

(注意,您还错误地指定了“月”视图按钮,这就是为什么该按钮没有显示的原因。我在演示中也纠正了这一点,如下所示:
正确:“dayGridMonth,timeline3Months”


另外,这里有一个在文档中创建自定义资源启用时间线视图的示例,位于

,下面的答案对您有帮助吗?如果是,请投票/接受。如果没有,请评论,以便我可以改进它。谢谢