我的路线设计如下: APP.js
<Switch>
<Route exact path="/" component={Home}/>
<Route path="/:category/:postId" component={Posts}/>
<Route path="/:category" component={Categories}/>)}/>
</Switch>
index.js:
<BrowserRouter >
<App/>
</BrowserRouter>
的index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-
to-fit=no">
<meta name="theme-color" content="#000000">
<link rel="stylesheet" href="./bootstrap-3.3.7-dist/css/bootstrap.min.css">
<link rel="stylesheet" href="./font-awesome-4.7.0/css/font-awesome.min.css">
<title>React App</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
</body>
</html>
当我通过“/”到“/ react / 8xf0y6ziyjabvozdd253nd”时,它工作了。但是刷新页面后反应 - bootstrap不起作用。我想知道为什么。我的代码被推了https://github.com/tulipjie/redux-readable
答案 0 :(得分:0)
从index.html中删除样式表<link>
并将其放在index.js
<强> index.js 强>
import 'bootstrap-3.3.7-dist/css/bootstrap.min.css';
import 'font-awesome-4.7.0/css/font-awesome.min.css';
// ... rest of your code here
假设您已从npm安装了上述软件包,并且位于/ node_modules。