Bootstrap suddenly not working for my React JS project

你离开我真会死。 提交于 2019-12-02 01:44:20

问题


Out of the blue bootstrap has stopped working on my project. I have no idea why.

Here is our 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"
  }
}

Here is our import in index.html

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

Any help/advice/suggestions would be much appreciated! Thanks!


回答1:


This:

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

is loading the latest version of Bootstrap which is 4.0.0.

And because Bootstrap 4 is totally incompatible with Bootstrap 3 that breaks your layout.

Solution:

Either load the css (as well as the corresponding js) files for Bootstrap 3 OR migrate to Bootstrap 4.

Bootstrap 3 links:

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

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


来源:https://stackoverflow.com/questions/48626950/bootstrap-suddenly-not-working-for-my-react-js-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!