'对象'类型上不存在属性'事件'

时间:2018-05-06 08:31:18

标签: angular typescript fullcalendar fullcalendar-2

我有这个方法,我使用FullCalendar加载事件,但我一直收到错误:

  

错误TS2339:“对象”类型中不存在属性“事件”。

这是我的方法:

loadInfo() {
this.userService.getChallengesByUserId(2).then(data => {
  this.userChallenges = data;
  this.userChallenges.forEach(ch => {
    var obj = {
      id: ch.challengeId,
      title: 'plz work'.toString(),
      start: ch.startDate,
      end: ch.endDate
    };
    this.calendarEvents.push(obj);
  });
  this.calendarOptions.events = this.calendarEvents;
  $('#myCalendar').fullCalendar('renderEvents', this.calendarEvents, true);
});

}

这是calendarOptions:

calendarOptions: Object = {
height: 'parent',
header: {
  left: 'title',
  center: '',
  right: 'today prev,next'
},
//  fixedWeekCount: false,
defaultDate: Date.now(),
editable: false,
eventLimit: true, // allow "more" link when too many events
views: {
  month: {
    eventLimit: 5
  }
},
eventClick: this.alertOnEventClick,
events: []

};

即使我打印console.log(this.calendarOptions),我也可以看到events存在

0 个答案:

没有答案