Webpack加载物化-css,无法读取未定义的属性

2022-04-17 00:00:00 javascript webpack materialize
一切运行正常,但当我从"crypto-js"导入CryptoJS时,它显示错误。我不知道为什么导入无关的东西会破坏物化-css?以前也发生过这种情况。Webpack太难相处了。如有任何线索,我们不胜感激。谢谢!

TypeError:无法读取未定义的属性‘Swing’ (匿名函数) Node_modules/materialize-css/dist/js/materialize.js:42

  39 | })(function ($) {
  40 | 
  41 |   // Preserve the original jQuery "swing" easing as "jswing"
> 42 |   $.easing['jswing'] = $.easing['swing'];
  43 | 
  44 |   var pow = Math.pow,
  45 |       sqrt = Math.sqrt,

"jQuery":"^3.2.1","物化-css":"^0.100.1",

new webpack.ProvidePlugin({
      $: "jquery",
      jQuery: "jquery",
      'window.jQuery': "jquery",
      'window.$': "jquery",
      "Hammer": "hammerjs/hammer",
      Materialize: 'materialize-css/dist/js/materialize.js',
      "window.Materialize": 'materialize-css/dist/js/materialize.js',
    }),

解决方案

我的基金不需要通过WebPackage导入。Provia Plugin,只需导入index.js(条目)中的物化-css/dist/js/Materialize.js就解决了问题。可能是因为它是在jQuery加载之前加载的。

相关文章