【发布时间】:2018-09-06 19:33:16
【问题描述】:
我在 React js 中创建了一个应用程序。在开发模式下一切正常,但在构建路由后无法正常工作。
我的 package.json 文件代码
{ "homepage": "http://localhost/hositng/react/",
"private": true,
"entry": {
"index": "./index.js"
},
}
我的路线文件代码
const Routes = () => (
<BrowserRouter basename="http://localhost/hositng/react" >
<Switch>
<Route exact path='/' component={Login} />
<Route path='/login' component={Login} />
<Route path='/home' component={Home} />
<Route path='/contact' component={Contact} />
</Switch>
</BrowserRouter>);
react build 命令后,当我点击“http://localhost/hositng/react/”url 时
- 应该进入登录页面,但进入主页
-
当点击联系我们页面链接时,联系页面 url 正在发生变化。
它应该转到这个网址“http://localhost/hositng/react/contact” 但 它将转到“http://localhost/contact”这个网址
但是当我用这个 url 刷新浏览器“http://localhost/contact”时,空白页来了
【问题讨论】:
标签: reactjs react-redux react-router