我的JavaScript出现问题,当我尝试运行该页面时,它始终会返回下一个错误,并且不会加载该页面的组件。
错误:未被捕获的TypeError:$(...)。HSMegaMenu不是函数
我的代码:
<script>
$(window).on('load', function () {
// initialization of HSMegaMenu component
$('.js-mega-menu').HSMegaMenu({
event: 'hover',
pageContainer: $('.container'),
breakpoint: 767,
hideTimeOut: 0
});
});
$(document).on('ready', function () {
// initialization of header
$.HSCore.components.HSHeader.init($('#header'));
// initialization of unfold component
$.HSCore.components.HSUnfold.init($('[data-unfold-target]'), {
afterOpen: function () {
$(this).find('input[type="search"]').focus();
}
});
// initialization of forms
$.HSCore.helpers.HSFocusState.init();
// initialization of form validation
$.HSCore.components.HSValidation.init('.js-validate');
// initialization of fancybox
$.HSCore.components.HSFancyBox.init('.js-fancybox');
// initialization of slick carousel
$.HSCore.components.HSSlickCarousel.init('.js-slick-carousel');
// initialization of slick carousel
$.HSCore.components.HSMalihuScrollBar.init($('.js-scrollbar'));
// initialization of go to
$.HSCore.components.HSGoTo.init('.js-go-to');
});
</script>