简体   繁体   中英

How to add javascript external file like bootstrap , jQuery to reactjs app

I am new to ReactJs, I have bootstrap.min.js , jquery.min.js , etc static file in my assets folder. I have to add those file to my ReactJs App, I had tried but it's not working.

I had added the below code to the index.html but it's not working

<script src="./assets/js/jquery.min.js"></script>
<script src="./assets/js/bootstrap4.min.js"></script>
<script src="./assets/js/vendor/Chart.bundle.min.js"></script>

The best way which I have used is via npm (yarn) package which you can directly install bootstrap into your project

npm install react-bootstrap bootstrap

Other users have mentioned using npm install <package> . If you've used create-react-app (or have yarn installed) I wanted to add that you can also use yarn add <package> for jQuery. Both work well.

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