我正在尝试初始化和销毁一个依赖于窗口宽度的mCustomScrollBar滚动条插件( es6应用程序中的一些JQueryJQuery.jQuery.jQuery)。但是,我在调整窗口大小时出现错误:
“未捕获函数:$(…) TypeError不是一个函数”。
下面是我的代码:
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();有人能指出我哪里错了吗?
https://stackoverflow.com/questions/41309711
复制相似问题