我正在尝试在我的 magento 2 站点上使用 willmcpo/body-scroll-lock ,但我认为我没有正确包含 body-scroll-lock 库,因为它说:
TypeError: disableBodyScroll 不是函数
有谁知道这样做的正确方法是什么?
main.js
require([
'jquery',
'bodyScrollLock'
], function ($) {
$(function(){
const
// bodyScrollLock = require('body-scroll-lock');
disableBodyScroll = bodyScrollLock.disableBodyScroll,
enableBodyScroll = bodyScrollLock.enableBodyScroll,
scrollMobileMenu = document.querySelector('.mobile-menu');
disableBodyScroll(scrollMobileMenu);
});
});
需要js-config.js
var config = {
map: {
"*": {
'bodyScrollLock': 'js/libs/bodyScrollLock'
}
},
deps: [
'bodyScrollLock'
]
};