Webpack load materialize-css,无法读取未定义

时间:2017-08-22 20:58:53

标签: javascript webpack materialize

一切运作良好,但是当我从“crypto-js”导入CryptoJS时,它显示错误。我不知道为什么导入无关的东西会破坏materialize-css?它也发生在以前。 webpack很难。任何线索都表示赞赏。谢谢!

TypeError:无法读取undefined的属性'swing' (匿名功能) node_modules /物化-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”,“materialize-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',
    }),

1 个答案:

答案 0 :(得分:0)

我资金我不需要通过webpack.ProvidePlugin导入,只需导入index.js(entry)中的materialize-css / dist / js / materialize.js即可解决问题。可能是因为它是在加载jQuery之前加载的。