React-Bootstrap 需要 npm install bootstrap 和 bootstrap CDN 还是只需要其中之一?

Does React-Bootstrap need both npm install bootstrap and bootstrap CDN or just one of them?

看过两种React教程-Bootstrap.

有时教程显示安装 React-BootstrapBootstrapnpm install react-bootstrap bootstrap 然后在 index.html.

中为 Bootstrap 添加 CDN link

然后在其他教程中,它只是 npm install react-bootstrap + CDN for Bootstrap in index.html


例如,名为 Brice Ayres 的 Youtuber 有这个视频:https://www.youtube.com/watch?v=tOK9l5uP06U ,

他用 React、React-Bootstrap、React-Router 和 Styled-Components 创建了一个网站。

在视频中,他安装了 React-BootstrapBootstrap,然后添加了CDN link.


在 React-Bootstrap 主页 https://react-bootstrap.github.io/getting-started/introduction 上,有这样一段文字:

If you plan on customizing the Bootstrap Sass files, or don't want to use a CDN for the stylesheet, it may be helpful to install vanilla Bootstrap as well.

所以我认为程序员是选择使用 NPM 安装 Bootstrap 还是使用 CDN link。两者兼而有之听起来有点奇怪。

或者我误解了 NPM Bootstrap 包的用例?因为我认为它和CDN样式表是一样的样式表?


长话短说:只安装 react-bootstrap 然后添加 CDN 就够了吗?

您需要 Bootstrap.css 文件,因为它不是 reactstrap 包的一部分...

为此,您需要

  1. npm install bootstrap 并通过一个引用 css 文件 import 在你的 JS 中声明
  2. 在 index.html 文件中添加 CDN <link href=' ../>...

为了部署您的网络项目,CDN 将为全球受众提供更大的覆盖范围,因此您必须根据您的独特因素权衡 CDNlocal package 价值主张