问题
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