我想在react中使用bootstrap模板,无法使用javascript文件

I want to use the bootstrap template in react , unable to use javascript files

提问人:Rohith 提问时间:11/15/2023 最后编辑:James HibbardRohith 更新时间:11/17/2023 访问量:62

问:

我想尝试在 React 中使用引导模板。我在组件页面中导入了所有CSS文件。

enter image description here

但是我无法使用JavaScript文件。我把它们导入体内。为了正常工作,我该怎么办?public/index.html

I tried this for css, css is working fine我为CSS尝试了这个。CSS工作正常

I tried adding js here ,but did not work我尝试在这里添加jS,但没有用

javascript 反应js 引导-4

评论

0赞 James Hibbard 11/15/2023
使用 npm 安装 Bootstrap,然后使用 将其导入到应用的入口点。看这里: stackoverflow.com/questions/43722322/...import
0赞 Rohith 11/16/2023
好的会检查谢谢

答:

-1赞 Nishant Fulara 11/15/2023 #1

我认为为了确保 JS 顺利运行,您需要使用文档中提到的脚本,如需更多参考,请不要忘记查看文档 -> https://react-bootstrap-v4.netlify.app/getting-started/introduction

<script src="https://unpkg.com/react/umd/react.production.min.js" crossorigin></script>

<script
  src="https://unpkg.com/react-dom/umd/react-dom.production.min.js"
  crossorigin></script>

<script
  src="https://unpkg.com/react-bootstrap@next/dist/react-bootstrap.min.js"
  crossorigin></script>