mCustomScrollBar: Uncaught TypeError: $(...).mCustomScrollBar is not a function on window resize

mCustomScrollBar: Uncaught TypeError: $(...).mCustomScrollBar is not a function on window resize

我正在尝试根据 window 的宽度初始化和销毁​​ mCustomScrollBar 滚动条插件(es6 应用程序中的一些 jquery,使用 webpack/babel 拖延)。但是,在调整 window 大小时出现错误:

"Uncaught TypeError: $(…).mCustomScrollBar is not a function".

这是我的代码:

function initCustomScrollbar() {
    var scrollPane = document.querySelector(".scroll-content");
    var scrollPaneInit = $(scrollPane).mCustomScrollbar();

    setTimeout(function () {
        var scrollInnerPane = $(scrollPane).find(".mCustomScrollBox");
        $(scrollInnerPane).height(window.innerHeight + "px");
    }, 500);

    $(window).resize(function () {
        if (window.innerWidth < 768) {
            initCustomScrollbar();
        } else {
            $(scrollPane).mCustomScrollBar('destroy');
        }
    });
}

initCustomScrollbar();

谁能指出我哪里错了?

我已经解决了这个问题,不知何故我的潜意识忘记了 Javascript 区分大小写...函数应该是:

$(scrollPane).mCustomScrollbar();

没有

$(scrollPane).mCustomScrollBar();

嗯!!!