Angular7 FullCalendar错误:无法读取未定义的属性“ length”

时间:2019-08-10 15:27:45

标签: angular fullcalendar

我正在干净的Angular 7.2.0应用程序上试用FullCalendar 4.3版。我正在关注this official guide。当我加载一个简单的空日历时,它可以正常工作。一旦添加任何事件并且应该显示该事件,它将引发错误而不显示该事件。

带事件的完整日历(从文档中复制):

<full-calendar
  defaultView="dayGridMonth"
  [plugins]="calendarPlugins"
  [weekends]="false"
  [events]="[
    { title: 'event 1', date: '2019-08-06' },
    { title: 'event 2', date: '2019-08-07' }
  ]"
></full-calendar>

错误:

ERROR TypeError: Cannot read property 'length' of undefined
    at DayGridView.push../node_modules/@fullcalendar/core/main.esm.js.View.computeEventDraggable (main.esm.js:7575)
    at DayGridEventRenderer.push../node_modules/@fullcalendar/daygrid/main.esm.js.SimpleDayGridEventRenderer.renderSegHtml (main.esm.js:218)
    at DayGridEventRenderer.push../node_modules/@fullcalendar/core/main.esm.js.FgEventRenderer.renderSegEls (main.esm.js:7799)
    at DayGridEventRenderer.push../node_modules/@fullcalendar/core/main.esm.js.FgEventRenderer.renderSegs (main.esm.js:7763)
    at DayGrid.res [as renderFgEvents] (main.esm.js:3183)
    at DayGrid.push../node_modules/@fullcalendar/daygrid/main.esm.js.DayGrid.render (main.esm.js:742)
    at DayGrid.push../node_modules/@fullcalendar/core/main.esm.js.Component.receiveProps (main.esm.js:3881)
    at SimpleDayGrid.push../node_modules/@fullcalendar/daygrid/main.esm.js.SimpleDayGrid.render (main.esm.js:1518)
    at SimpleDayGrid.push../node_modules/@fullcalendar/core/main.esm.js.Component.receiveProps (main.esm.js:3881)
    at DayGridView.push../node_modules/@fullcalendar/daygrid/main.esm.js.DayGridView.render (main.esm.js:1584)

1 个答案:

答案 0 :(得分:1)

我在github上发现了this example angular project,效果很好。我从scatch重新创建了项目,将FullCalendar版本更新为4.3.0(最新),没有任何问题。我无法弄清楚原始应用程序出了什么问题,但是,如果有人无法正常工作,示例项目会有所帮助。