【问题标题】:How to fix Uncaught TypeError: Cannot call method 'call' of undefined in fullcalendar如何修复未捕获的类型错误:无法在完整日历中调用未定义的方法“调用”
【发布时间】:2019-07-25 08:15:08
【问题描述】:

我正在使用 phonegap 开发应用程序,并且需要使用全日历“可选”功能。这些应用程序在手机中运行良好。但安装到平板电脑时,点击任何日历都会显示此错误:

07-25 16:12:37.676: I/chromium(4707): [INFO:CONSOLE(128)] "Uncaught TypeError: Cannot call method 'call' of undefined",来源:file:///android_asset/ www/apis/fullcalendar/core/main.js (128)

为什么它只发生在平板电脑上,但在我的手机上却可以正常工作

这些是我在我的 html 中导入的脚本:

<link href='apis/fullcalendar/core/main.css' rel='stylesheet' />
<link href='apis/fullcalendar/daygrid/main.css' rel='stylesheet' />
<script src='apis/fullcalendar/core/main.js'></script>
<script src='apis/fullcalendar/interaction/main.js'></script>
<script src='apis/fullcalendar/daygrid/main.js'></script>

这就是我创建日历的方式

    var today = moment().format('YYYY[-]MM[-]DD');
    var eventList = new Array();

    $.each(
        holidayDateList,
        function(i,v) {
            var events = {
                title: holidayNameList[i],
                start: v,
                backgroundColor: "#8c8c8c"
            };

            eventList.push(events);
        });

    $.each(
        offdayServerDateList,
        function(i,v) {
            var events = {
                title: offdayServerReasonList[i],
                start: v
            };

            eventList.push(events);
        });

    $.each(
        offdayDateList,
        function(i,v) {
            var events = {
                title: offdayReasonList[i],
                start: v
            };

            eventList.push(events);
        });

    var calendarEl = document.getElementById('calendar');

    var calendar = new FullCalendar.Calendar(calendarEl, {
        plugins: [ 'interaction', 'dayGrid' ],
        defaultDate: today,
        editable: false,
        selectable: true,
        selectMirror: true,
        select: function(arg) {
            var isToday = moment(arg.start).format('YYYY[-]MM[-]DD') == today;
            var isAfterToday = moment(arg.start).isAfter(today);
            var isHolidayDate = holidayDateList.indexOf(moment(arg.start).format('YYYY[-]MM[-]DD')) >= 0;
            var isOffdayDate = offdayServerDateList.indexOf(moment(arg.start).format('YYYY[-]MM[-]DD')) >= 0;

            if((isAfterToday || isToday) && !isHolidayDate && !isOffdayDate) {
                $("#dialog-form").dialog("open");
            }
        },
        eventLimit: true,
        eventClick: function(info) {
            var isOffdayDate = offdayServerDateList.indexOf(moment(info.event.start).format('YYYY[-]MM[-]DD')) >= 0;

            if(isOffdayDate) {
                alert("Open delete reason dialog for " + moment(info.event.start).format('YYYY[-]MM[-]DD'));
            } else {
                alert(info.event.title);
            }
        },
        events: eventList
    });

    calendar.render();

更新:我使用 samsung j5 pro (android oreo) 作为我的手机测试设备,该设备可以正常工作。有问题的设备是我的三星 Galaxy Tab 3(android kitkat)。还尝试在 nox 播放器上安装应用程序,设置为电话和桌子。但也不能工作

【问题讨论】:

  • 哪款平板电脑?哪个操作系统(和版本)?哪个浏览器(和版本)?我们可以看看你的代码吗?我们无法猜测您的环境的详细信息。它完全无法在任何“平板电脑”上工作并不是一个已知问题,因此我们需要一些细节。了解有关其工作的手机的相同详细信息也可能会有所帮助,以便我们进行比较。
  • @ADyson 我更新了一些细节。希望有帮助
  • 您能否在平板电脑上的浏览器(例如 Chrome)中加载codepen.io/ADyson82/pen/dxXeBW,看看您是否有选择问题? (P.S. 我不得不注释掉很多代码,因为我无权访问您的事件数据,但也许您可以将其重新引入 CodePen 以使其更准确地显示您的确切代码)。在浏览器中进行测试的目的是查看问题是否与 phonegap 有关。
  • @ADyson 在 chrome 75.0.3770.143 应用上尝试过,但没有任何显示。我什至将 console.log 更改为警报。但什么都没有弹出
  • 您知道这里的设置:fullcalendar.io/docs/touch 吗?您可能需要长按才能启动选择事件。

标签: javascript fullcalendar phonegap fullcalendar-4


【解决方案1】:

好像当我在我的标签上运行代码时。 js 无法识别 Core/main.js 中提供的任何匹配方法

我需要在第 107 行的匹配方法选择期间添加 webkitMatchesSelector,因此如果其他方法未定义,代码将使用该匹配方法。

原文:

var matchesMethod = Element.prototype.matches ||
Element.prototype.matchesSelector ||
Element.prototype.msMatchesSelector;

更新:

var matchesMethod = Element.prototype.matches ||
Element.prototype.matchesSelector ||
Element.prototype.msMatchesSelector || 
Element.prototype.webkitMatchesSelector; // add this

参考:https://github.com/matsko/ng4-animations-preview/issues/1

【讨论】:

    猜你喜欢
    • 2012-10-21
    • 2013-08-31
    • 2011-11-12
    • 2013-09-14
    • 2013-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多