0

我正在尝试在我的 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'
  ]
};
4

1 回答 1

0

想通了,我只需要在此处包含 bodyScrollLock

], function ($, bodyScrollLock) {
于 2020-05-05T13:26:08.350 回答