【发布时间】:2019-06-10 08:36:12
【问题描述】:
我想在我的网络应用程序中使用引导程序,我已经成功地包含了 css,但我在包括用于显示模式、警报等的引导程序 JavaScript 时遇到了困难。
在我的 package.json 中,我有以下内容:"bootstrap": "^4.2.1", 在 index.js 中我有这样的东西:
import '../node_modules/bootstrap/dist/js/bootstrap.bundle.min';
在我的 html 中,我有以下内容:
<div className="modal fade bd-example-modal-lg" tabIndex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div className="modal-dialog modal-lg">
<div className="modal-content">
asdasdasd
</div>
</div>
</div>
我得到的错误是:
找不到模块:无法解析“C:\Users\iluli\Desktop\Work\atop\atop\node_modules\bootstrap\dist\js”中的“jquery”
我还能如何在我的 react 应用中包含 bootstrap js。
【问题讨论】:
-
你还需要包含 jQuery。
-
如果我选择使用 React 为什么我还需要 jQuery?我可以在没有 jQuery 的情况下使用 react 吗?
-
@Mizlul 你可以在没有 jquery 的情况下使用 react。你不能在没有 jquery 的情况下使用 Bootstrap.js
-
Bootstrap 需要 jQuery。因此,使用 react 或其他任何东西都没有关系。
-
我明白了,我该如何修复它,只需要像 npm install jquery 这样运行 smth?
标签: javascript html reactjs bootstrap-4