在laravel 5.4 mix上添加jQuery
我已经熟悉了laravel 5.1 mix(elixir),最近我决定测试laravel 5.4 mix。
我在供应商文件上混合了我的库。
mix .styles([ './node_modules/bootstrap/dist/css/bootstrap.css', './node_modules/font-awesome/css/font-awesome.css' ], 'public/css/vendor.css') .js([ './node_modules/jquery/dist/jquery.js', './node_modules/bootstrap/dist/js/bootstrap.js', ], 'public/js/vendor.js') .disableNotifications() .version();
并在我的页面上包含供应商。
但是,当我想使用jQuery时,我在下面的图像上有这个错误。 之前,在laravel 5.1中,我的确如此。
我需要做什么?
只需在assets/js/bootstrap.js
文件中取消注释该行:
window.$ = window.jQuery = require('jquery');
并确保在您的assets/js/app.js
需要bootstrap文件,如下所示:
require('./bootstrap');
mix.autoload({ 'jquery': ['window.$', 'window.jQuery'] })
我不得不将它添加到我的webpack.mix.js