我在一页上显示了一个日历,但我无论如何也不能让它工作。我在控制器中创建了一个数组,将其传递给视图json_encoded,但是fullcalendar不想提取该数组并将其弹出到日历中。下面是我的代码:
HomeController
public function calendar_feed(){
return response()->json(
[
'title' => 'Matts Booking',
'start' => '2018-01-01T22:40',
'end' => '2019-01-01T23:40'
], 200
);
}
完整日历函数
<script type="text/javascript">
(function ( $ ) {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay,listWeek'
},
editable: false,
defaultView: 'agendaWeek',
firstDay: 1,
eventLimit: false, // allow "more" link when too many events
navLinks: true,
events: '{{ route("calendar_feed") }}'
});
}( jQuery ));
</script>
阵列发送给的内容
{"title":"Matts Booking","start":"2018-01-01T22:40","end":"2019-01-01T23:40"}
任何帮助都将不胜感激!
非常感谢
发布于 2018-06-10 06:35:54
根据属性events
和array example的名称,它看起来需要一个数组,因此添加一对额外的方括号:
public function calendar_feed(){
return response()->json([[
'title' => 'Matts Booking',
'start' => '2018-01-01T22:40',
'end' => '2019-01-01T23:40'
]], 200
);
}
现在返回一个只有一个元素的对象数组。
https://stackoverflow.com/questions/50778917
复制相似问题