2
我試圖讓jQuery與Laravel 5.4一起工作。我用npm安裝了jQuery。我在同一個文件夾中有兩個文件:app.js
和bootstrap.js
。從app.js
我導入文件bootstrap.js
有:如何讓jQuery與Laravel一起工作?
require('./bootstrap');
在bootstrap.js
我導入jQuery的有:
window.$ = window.jQuery = require('jquery');
仍然在我的刀片觀點,當我嘗試:
<script>
$(document).ready(function() {
console.log('jQuery is working!');
});
</script>
我得到一個參考錯誤告訴我「$未定義」。
任何想法我做錯了什麼?先謝謝你。
是的!但是我在'script'標記中設置了'async'屬性設置爲'async'。解決了! – louisfischer