【问题标题】:Error Uncaught TypeError: Cannot read property 'hasTime' of undefined on full calendar错误未捕获类型错误:无法读取完整日历上未定义的属性“hasTime”
【发布时间】:2019-02-14 11:34:19
【问题描述】:

我在使用 laravel 框架时遇到了完整日历的问题。我尝试将我的表格中的数据显示为完整的日历,但显示错误。

Error Uncaught TypeError: Cannot read property 'hasTime' of undefined

这是我的控制器

public function calendarmodul()
{
    $caledarmodul = Modul::all();
    return $caledarmodul;
}

这是我的观点

 $(function () {  
  $('#calendar').fullCalendar({
    eventSources: [
        {
          url: "{{ url('calendar-modul') }}",
          type:"GET",
          dataType: "JSON",
          error: function() 
          {
            alert("error");
          },
          success: function()
          {
              console.log("successfully loaded");
          }
        }
    ],
    editable  :false,
    droppable :false,
  })
});

【问题讨论】:

    标签: jquery ajax laravel fullcalendar


    【解决方案1】:

    这是因为您为完整日历提供了错误的参数。 您的 JSON 数据应如下所示:

        {
          title: 'Event Title1',
          start: '2015-03-17T13:13:55.008',
          end: '2015-03-19T13:13:55.008'
        },
        {
          title: 'Event Title2',
          start: '2015-03-17T13:13:55-0400',
          end: '2015-03-19T13:13:55-0400'
        }
    

    控制台记录您的回复并检查它是否与完整日历的格式匹配。

    也将您的响应返回为 json

    return json_encode($data);
    

    要选择自定义字段,您可以执行以下操作:

    $data = Modul::select('name as title', 'start_date as start', 'end_date as end'->get();
    

    【讨论】:

      猜你喜欢
      • 2021-11-07
      • 1970-01-01
      • 2017-11-14
      • 2017-02-11
      • 1970-01-01
      • 2017-07-26
      • 2021-12-22
      • 2015-01-06
      相关资源
      最近更新 更多