zoukankan      html  css  js  c++  java
  • fullcalendar从后台获取events报Uncaught TypeError: callback is not a function

            今天恰逢1024程序员节,祝包括自己在内的程序员们身体健康,收入多多!

      用fullcalendar做了一个简单的工作日和休息日的排班功能,因为现公司是大小休模式,即一周双休一周单休。把是否上班设置为event的title,events从后台获取:

     1             //获取数据后显示在fullcalendar页面
     2             events: function(start, end, callback) {
     3                 var fstart = moment(start).format("yyyy-MM-dd");
     4                 var fend = moment(end).format("yyyy-MM-dd");
     5                 $.ajax({
     6                     type: "post",
     7                     url: "/system/getWorkdayInfos",
     8                     dataType: "json",
     9                     data: {
    10                         start: fstart,
    11                         end: fend
    12                     },
    13                     success: function(data) {
    14                         if (data.success) {
    15                             var events = [];
    16                             $.each(data.data, function(i) {
    17                                 var status = data.data[i].workStatus==1?"班":"休";
    18                                 events.push({
    19                                     title: status,
    20                                     start: moment(data.data[i].date).format("YYYY-MM-DD"),
    21                                     end: moment(data.data[i].date).format("YYYY-MM-DD"),
    22                                     allDay: true
    23                                 });
    24                             });
    25                             callback(events);
    26                         } else {
    27                             alert(data.description);    
    28                         }
    29                     }
    30                 });
    31             },

      运行总是报错:

        

      搜索发现本人用的fullcalendar版本的events方法缺少一个参数:timezone,参考网页:https://bbs.csdn.net/topics/392283087?mType=Group。添加该参数后,果然不再报错。正确的events方法定义为:

    events: function(start, end, timezone, callback) {
      ...  
    }
  • 相关阅读:
    vue中判断APP 为ios系统 安卓系统 浏览器判断 微信 qq 支付宝
    vconsole调试工具使用
    vue 电话号中间四位****代替
    vue中使用倒计时
    在APP中ios输入账号和密码时键盘闪烁
    vue中返回随机数
    vue 阿里云的滑动验证
    从零开发一套完整的vue项目开发环境
    vue中修改第三方组件中的样式
    nginx 启动报错dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  • 原文地址:https://www.cnblogs.com/GreenMountain/p/9841899.html
Copyright © 2011-2022 走看看