未捕获的TypeError:$(...)in laravel mix

时间:2017-10-29 22:49:09

标签: jquery laravel jquery-plugins laravel-5.5 laravel-mix

current以下列方式设置我的webpack.mix.js:

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css');

脚本:

<script src="{{ mix('js/app.js') }}"></script>
<script type="text/javascript" src="js/jquery-scrolltofixed.js"></script>
<script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="js/jquery.isotope.js"></script>
<script type="text/javascript" src="js/wow.js"></script>
<script type="text/javascript" src="js/classie.js"></script>
<script src="/js/jquery.dynamicmaxheight.js" type="text/javascript"></script>
<script src="js/slick.js" type="text/javascript" charset="utf-8"></script>

app.js

require('./bootstrap');

bootstrap.js

window._ = require('lodash');

try {
    window.$ = window.jQuery = require('jquery');

    require('bootstrap-sass');
} catch (e) {}

对于顶级代码,一切正常。

现在我想将所有脚本文件合并到一个文件中。

所以我按照以下方式设置了我的webpack.mix.js:

mix.js(['resources/assets/js/app.js',
        'resources/assets/js/jquery-scrolltofixed.js',
        'resources/assets/js/jquery.easing.1.3.js',
        'resources/assets/js/jquery.isotope.js',
        'resources/assets/js/wow.js',
        'resources/assets/js/classie.js',
        'resources/assets/js/jquery.dynamicmaxheight.js',
        'resources/assets/js/slick.js',
        'resources/assets/js/sweetalert2.all.min.js'
      ], 'public/js/main.js')
      .autoload({
      jquery: ['$', 'window.jQuery']
      })
      .sass('resources/assets/sass/app.scss', 'public/css')
      .styles([
        'resources/assets/css/slick.css',
        'resources/assets/css/slick-theme.css',
        'resources/assets/css/responsive.css',
        'resources/assets/css/animate.min.css',
        'resources/assets/css/sweetalert2.min.css'
      ],'resources/assets/css/style.css')
      .combine(['public/css/app.css','resources/assets/css/style.css'], 'public/css/main.css');

和html doc中的脚本部分:

<script src="{{ mix('js/main.js') }}"></script>

和app.js

require('./bootstrap');
require('sweetalert');

和bootstrap.js没有变化。

使用npm run dev,它构建成功,但插件不起作用。

我得到这样的错误:

  

未捕获的ReferenceError:未定义jQuery

     

未捕获的TypeError:$(...)。slick不是函数

     

未捕获的TypeError:$(...)。dynamicmaxheight不是函数

     

Uncaught TypeError:$(...)。wow不是函数

0 个答案:

没有答案