我在ReactJs组件上使用jQuery fullcalendar.
我有一个 <div id="calendar"></div>渲染方法
在componentDidUpdate上,我使用以下代码更新了日历:
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
events: _this.state.events,
defaultView:'month',
displayEventTime: false,
editable: false,
droppable: false,
durationEditable: false
});
Run Code Online (Sandbox Code Playgroud)
它在标题上显示"未定义"字符.我哪里做错了?以及如何调试未定义字符串的来源?
目前,我做了一个被黑客攻击的解决方案,通过添加以下内容从标题中删除所有未定义的字符串:
viewRender: function(view, element) {
//note: this is a hack, i don't know why the view title keep showing "undefined" text in it.
//probably bugs in jquery fullcalendar
$('.fc-center')[0].children[0].innerText = view.title.replace(new RegExp("undefined", 'g'), ""); ;
},
Run Code Online (Sandbox Code Playgroud)
还有更好的解决方案吗?
我正在使用jquery FullCalendar v2.9.1
以下有关事件的示例数据:
[{"start":"2017-03-24T00:00:00.000Z","end":"2017-03-26T00:00:00.000Z","title":"Open house","description":"Bali 1 open house"}]
Run Code Online (Sandbox Code Playgroud)
注意:我最终倾倒了jquery完整日历,转而使用react-big-calendar.