在 webpack 中为 bootstrap 指定 jQuery [英] Specify jQuery for bootstrap in webpack
本文介绍了在 webpack 中为 bootstrap 指定 jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的项目中,我想导入 Bootstrap,但它依赖于 jQuery.
In my project, I want to import Bootstrap, but it depends on jQuery.
require('jquery/dist/jquery.min');
require('bootstrap/dist/js/bootstrap.min');
我用Webpack处理这个项目的时候,报错:
When I use Webpack to handle this project, it causes an error:
Uncaught Error: Bootstrap's JavaScript requires jQuery
如何为 Bootstrap 指定 jQuery?
How can I specify jQuery for Bootstrap?
推荐答案
将您的 require
语句替换为以下内容:
Replace your require
statement with the following:
window.jQuery = window.$ = require('jquery/dist/jquery.min');
这篇关于在 webpack 中为 bootstrap 指定 jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文