Fullcalendar v2.6.0 是否能够在 jQuery-3.3.1 和 MVC 5 上工作?

Is Fullcalendar v2.6.0 able to work on jQuery-3.3.1 and MVC 5?

Fullcalendar v2.6.0 能否在 jQuery-3.3.1 和 MVC 5 上运行?我有一个需要升级的旧项目。我正在使用 Visual Studio 2017 和 jQuery-3.3.1,MVC 5.2.4 和 moment.min.js 2.24 重新编译它,但是当我使用 IE 11 时总是出错:

Unhandled exception at line 3827, column 3 in http://localhost:61158/Scripts/jquery-3.3.1.js 0x800a138f - JavaScript runtime error: Unable to get property 'format' of undefined or null reference

当我使用Google Chrome调试它时,我得到的错误信息是:

Uncaught TypeError: Cannot read property 'format' of null

有人有什么想法吗?谢谢。

抱歉,这是我在 index.cshtml 中的日历代码。

 <script type="text/javascript">

    $(document).ready(function() {

        $('#calendar').fullCalendar({
            theme: true,
            aspectRatio: 2,
            defaultDate: '@DateTime.Now.ToString("MM-dd-yyyy")',
            editable: true,
            eventLimit: true, // allow "more" link when too many events
            events: {
                url: '@Url.Action("GetCalendarEvents")',
                error: function () {
                    $('#script-warning').show();
                }
            },
            eventClick: function (calEvent, jsEvent, view) {
                //set the values and open the modal
                //var winWidth = $(window).width();
                //var dialogWidth = winWidth * 0.5;
                var gdiv = $("#eventInfo");
                if (gdiv != null) gdiv.empty();

                $.ajaxSetup({ cache: false });

                var request = $.ajax({
                    type: "GET",
                    url:  calEvent.ajaxUrl,
                    data: {}
                });

                request.done(function (returndata) {
                    $("#eventInfo").html(returndata);

                });


                request.fail(function (jqXHR, status) {
                    alert("Error repopulating grid : " + status + "");
                });

                $.ajaxSetup({ cache: true });

            }
        });

    });

    </script>

这是一个使用这些库版本的 JSFiddle(MVC 版本无关紧要,因为它只影响服务器端代码):http://jsfiddle.net/g2np7wt9/2/

不幸的是,您没有 post 自己的代码,因此我使用了非常基本的日历设置进行测试:

$(document).ready(function() {
  $('#calendar').fullCalendar({
    header: {
      left: 'prev,next today',
      center: 'title',
      right: 'month,agendaWeek,agendaDay'
    }
  });
});

它确实会产生您问题中提到的错误,所以简短的回答是否定的,这种库版本组合不起作用。

所以你的选择是

a) 降级 jQuery 的版本直到问题停止(根据一些快速测试,2.2.4 似乎是它使用的最后一个版本)

或(可能更好)

b) 升级您的 fullCalendar 版本,因为 2.x 现在是旧版本。 3.x 几乎 100% API 与 2.x 兼容,但确实适用于较新的 jQuery。参见 https://fullcalendar.io/blog/2016/09/feature-packed-releases. 4.x is a much bigger change but it may be worth it in the long run, since that's where the future lies in terms of new features, bug fixes etc. Also 4.x doesn't require jQuery or momentJS, so that headache would disappear entirely... see https://fullcalendar.io/docs/upgrading-from-v3

我已将 fullCalendar 升级到 V3.9,现在可以使用了。除了警告之外不再有错误:弃用警告:提供的值不是可识别的 RFC2822 或 ISO 格式。 moment 构造回退到 js Date(),这在所有浏览器和版本中都不可靠。不鼓励使用非 RFC2822/ISO 日期格式,并将在即将发布的主要版本中删除。请参阅 momentjs。com/guides/#/warnings/js-date 了解更多信息。 但至少日历在我的网络应用程序上正常工作。感谢大家的帮助。如果您对上述警告有任何想法,请告诉我。