[英]jQuery not working (ReactJS, Bootstrap, Webpack)
Using a create-react-app ejected project. 使用create-react-app弹出的项目。
I'm following this other stackoverflow answer: Using Jquery and Bootstrap with Es6 Import for React App 我正在关注这个其他stackoverflow的答案: 使用Jquery和Bootstrap与Es6 Import for React App
The problem is that jQuery isn't working at all in in production mode , even tho Bootstrap doesn't throw the error that jQuery isn't available. 问题是jQuery在生产模式下根本不工作,即使引导程序也没有抛出jQuery不可用的错误。
main.js: main.js:
// CSS
import 'bootstrap/dist/css/bootstrap.min.css';
import './theme/css/style.css';
import 'font-awesome/css/font-awesome.min.css';
// JS
import 'jquery';
import 'bootstrap/dist/js/bootstrap';
element that uses bootstrap+jquery: 使用bootstrap + jquery的元素:
<li id="user-menu" class="dropdown menu-merge pull-right">
<a aria-expanded="false" class="dropdown-toggle" data-toggle="dropdown">
<span>User</span>
<span class="caret ml10"></span>
</a>
<ul class="dropdown-menu w225" role="menu">
<li>
<a href="/admin/instance">
<span class="icon icon-Gear mr10"></span>
Config
</a>
</li>
</ul>
</li>
It simply won't open, unlike using webpack dev config, where it does. 它不会打开,不像使用webpack dev config那样。
What is going on? 到底是怎么回事?
Shouldn't your jQuery import be: 你的jQuery导入不应该是:
import $ from 'jquery';
instead of import 'jquery'
而不是
import 'jquery'
Also why not use React-Bootstrap instead? 另外为什么不使用React-Bootstrap呢? This doesn't seem worth the trouble.
这似乎不值得麻烦。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.