我使用 fullcalendar.io 插件,我想在日历的每个单元格中添加一些额外的 html,但在控制台中我收到以下错误:
Uncaught TypeError: Cannot read property 'append' of undefined at Calendar.dayRender (mycode.js?v=1.x:31) at Calendar.publiclyTrigger (main.js?v=1.x:6949) at DayGrid.DateComponent.publiclyTrigger (main.js?v=1.x:4008) at DayGrid._renderCells (main.js?v=1.x:796) at DayGrid.res [as renderCells] (main.js?v=1.x:3189) at DayGrid.render (main.js?v=1.x:740) at DayGrid.Component.receiveProps (main.js?v=1.x:3887) at SimpleDayGrid.render (main.js?v=1.x:1520) at SimpleDayGrid.Component.receiveProps (main.js?v=1.x:3887) at DayGridView.render (main.js?v=1.x:1586)
var calendarEl = document.getElementById('calendar'(;
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: [ 'dayGrid', 'timeGrid', 'list' ],
defaultView: 'dayGridMonth',//'timeGridWeek',
header: {
left: 'prevYear,prev,next,nextYear today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
},
defaultDate: '2019-07-12',
editable: true,
eventLimit: true, // allow "more" link when too many events
dayRender: function(date, element) {
element.append("<input type="checkbox">AM<br>");
}
});
我认为由于某种原因,dayRender没有定义elemement变量。为什么会这样?
在 Full Calendar v 4.0 中,按照 ADyson 的建议,按如下方式使用 dayRender:
dayRender: function (dayRenderInfo) {
dayRenderInfo.el.innerHTML = "<input type="checkbox">AM<br>";
}