我正在使用完整日历在完整日历中显示分配的班次以及开始和结束时间。我将获取数组中的数据,并将值映射到events。那里,如果我仅针对日期执行的话,它将正常工作。如果我在其中加上时间,它将不会显示事件。任何人都可以帮我解决这个问题。谢谢
let apiData = [["11/07/2018","10:00",,"16:00","morningShift"],["11/08/2018","10:00",,"16:00","Shift1"]] // dynamic
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var form = '';
var today = new Date($.now());
$('#calendar').fullCalendar({
slotDuration: '00:15:00', /* If we want to split day time each 15minutes */
minTime: '00:00:00', /* calendar start Timing */
maxTime: '24:00:00', /* calendar end Timing */
defaultView: 'month',
handleWindowResize: true,
height: $(window).height() - 200,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
events : apiData.map(([startDate,start,end,title])=>({
start: new Date(startDate)+'T'+start, //mapping date
// with time
end: new Date(startDate)+'T'+end,
title,
className: 'bg-primary'})
),
timeFormat: 'H(:mm)'
});
}
答案 0 :(得分:0)
我将后端的开始日期和时间串联起来,并将其传递给js。现在可以正常工作