Bootstrap 突然不适用于我的 React JS 项目

IT技术 node.js reactjs bootstrap-4 react-bootstrap package.json
2021-05-02 00:22:15

突然,引导程序停止了我的项目。我不知道为什么。

这是我们的 package.json:

  {
  "name": "blankets",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "amazon-cognito-identity-js": "^1.26.0",
    "aws-sdk": "^2.151.0",
    "bootstrap": "^4.0.0",
    "jwt-decode": "^2.2.0",
    "prop-types": "^15.6.0",
    "react": "^16.1.1",
    "react-bootstrap": "^0.31.5",
    "react-dom": "^16.1.1",
    "react-router-dom": "^4.2.2",
    "react-scripts": "1.0.17",
    "react-select": "^1.0.0-rc.10"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

这是我们在 index.html 中的导入

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">

任何帮助/建议/建议将不胜感激!谢谢!

1个回答

这:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">

正在加载最新版本的 Bootstrap,即 4.0.0。

并且因为 Bootstrap 4 与破坏你的布局的 Bootstrap 3 完全不兼容。

解决方案:

要么为 Bootstrap 3 加载 css(以及相应的 js)文件,要么迁移到 Bootstrap 4。

引导程序 3 链接:

https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css

https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js