0
所以我想用webpack
做一個構建。和編譯頁面拋出錯誤從webpack構建後,jquery無法識別
Uncaught ReferenceError: $ is not defined
at Object._typeof (bootstrap.js:30331)
at __webpack_require__ (bootstrap.js:20)
at Object.<anonymous> (bootstrap.js:27876)
at __webpack_require__ (bootstrap.js:20)
at Object.<anonymous> (bootstrap.js:70744)
at __webpack_require__ (bootstrap.js:20)
at bootstrap.js:66
at bootstrap.js:69
我未編譯
Bootstrap.js
window.$ = window.jQuery = require('jquery');
window._ = require('lodash');
window.Vue = require('vue');
window.axios = require('axios');
window.axios.defaults.headers.common = {
'X-CSRF-TOKEN': window.Laravel.csrfToken,
'X-Requested-With': 'XMLHttpRequest'
};
window.Pusher = require('pusher-js');
require('toastr');
require('jquery-slimscroll');
//Jquery sortable
require('jquery-sortable');
import "select2";
import "./metisMenu/jquery.metisMenu";
import "./dataTables/datatables.min";
import "./datapicker/bootstrap-datepicker";
import "./touchspin/jquery.bootstrap-touchspin.min";
import "./inspinia";
編譯我得到這個錯誤在瀏覽器中之後,但我沒有得到任何編譯錯誤
任何其他人都陷入了類似的問題?
謝謝
你可以從$「jQuery的」試-import; – MukulSharma
@MukulSharma抱歉沒有得到你,我已經將Jquery分配給那個變量na? – Vikram
我以前有過類似的問題。可能一些jquery插件不是CommonJS兼容的。嘗試使用['script-loader'](https://github.com/webpack-contrib/script-loader) – Ematipico