简体   繁体   中英

Bootstrap's JavaScript requires jQuery while creating react project

我面临的错误 I was using Bootstrap v3.3.6 and jQuery v2.2.4

Do i need to change the version not to get this error. I am having index.html like below

 <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 file

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')
 );

I am unable to see the UI, I am getting Bootstrap's JavaScript requires jQuery

From the given messages your jQuery Bootstrap and other files seem to not be properly set up and contain some errors and javascript is run on a single thread and hence it is terminating execution without reaching the completion of file and throwing the error. Please check your jQuery and Bootstrap files and try to use the CDN's from Getting Start with Bootstrap

As far as I am aware you have used imports wrong and if your index.html file has the src you are not required to import it within the index.js file and can use all the classes similarly. Please look at How to include third party libraries in React

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM