我已经熟悉 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();
并在我的页面上包含供应商。
<script src="{{ mix('js/vendor.js') }}" type="text/javascript" charset="utf-8" async defer></script>
但是,当我想使用 jQuery 时,我在下图中遇到了这个错误。之前,在 laravel 5.1 中我就是这样做的。
我需要做什么?
最佳答案
只需取消注释您的 assets/js/bootstrap.js
文件中的这一行:
window.$ = window.jQuery = require('jquery');
并确保在您的 assets/js/app.js
中需要 Bootstrap 文件,如下所示:
require('./bootstrap');
关于php - 在 laravel 5.4 mix 上添加 jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42631990/