【问题标题】:Bootstrap's JavaScript requires jQuery while creating react projectBootstrap 的 JavaScript 在创建反应项目时需要 jQuery
【发布时间】:2019-07-01 05:10:57
【问题描述】:

我使用的是 Bootstrap v3.3.6 和 jQuery v2.2.4

我是否需要更改版本才不会出现此错误。 我有 index.html 如下所示

 <html lang="en">
 <head>
     <link href="css/style.css" rel="stylesheet">
</head>
  <body class="nav-md">
 <div id="app"></div>
<script src="./js/jquery.min.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script src="./js/custom.min.js"></script>
<script src="/bundle.js"></script> 

 </body>

  </html>

Index.js 文件

import 'babel-polyfill';
 import React from 'react';
import ReactDOM from 'react-dom';
  import { Provider } from 'react-redux';
 import { Router, browserHistory } from 'react-router';
  import routes from './routes';


  import './css/bootstrap.min.css';
  import './css/custom.min.css';
  import './css/style.css';

   import './js/jquery.min.js';
   import './js/bootstrap.min.js';
    import './js/custom.min.js';





    import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
  import {indigoA200} from 'material-ui/styles/colors';
   import getMuiTheme from 'material-ui/styles/getMuiTheme';
 const muiTheme = getMuiTheme({
    palette: {
    primary1Color: indigoA200,
    primary2Color: indigoA200,
    },
  });

ReactDOM.render((
   <MuiThemeProvider muiTheme={muiTheme}>
    <Router history={browserHistory} routes={routes} />
</MuiThemeProvider>)
,document.getElementById('app')
 );

我看不到 UI,我得到 Bootstrap 的 JavaScript 需要 jQuery

【问题讨论】:

标签: javascript jquery reactjs react-redux


【解决方案1】:

从给定的消息来看,您的 jQuery Bootstrap 和其他文件似乎没有正确设置并包含一些错误,并且 javascript 在单个线程上运行,因此它在未完成文件并引发错误的情况下终止执行。 请检查您的 jQuery 和 Bootstrap 文件并尝试使用来自Getting Start with Bootstrap的 CDN

据我所知,你使用了错误的导入,如果你的 index.html 文件有 src,你不需要在 index.js 文件中导入它,并且可以类似地使用所有类。请看 How to include third party libraries in React

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-15
    • 1970-01-01
    • 2019-10-12
    • 2017-06-06
    • 2015-11-16
    • 2017-04-25
    • 2019-07-31
    • 2018-07-13
    相关资源
    最近更新 更多