[英]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.我是 ReactJs 的新手,我的资产文件夹中有
bootstrap.min.js
、 jquery.min.js
etc
静态文件。 I have to add those file to my ReactJs App, I had tried but it's not working.我必须将这些文件添加到我的 ReactJs 应用程序中,我已经尝试过但它不起作用。
I had added the below code to the index.html but it's not working我已将以下代码添加到index.html但它不起作用
<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 (yarn) 包,你可以直接将 bootstrap 安装到你的项目中
npm install react-bootstrap bootstrap
Other users have mentioned using npm install <package>
.其他用户提到使用
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.如果您使用过
create-react-app
(或安装了 yarn),我想补充一点,您也可以为 jQuery 使用yarn add <package>
。 Both work well.两者都运作良好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.