【发布时间】:2018-12-13 10:11:12
【问题描述】:
我正在尝试从 react-router-v4 实现 React HashRouter...当我使用所有按钮浏览页面时,它可以完美运行...
但是在页面刷新时我得到了一个奇怪的行为。愿你们中的某个人能帮助我。这是我的代码:
<HashRouter basename='/app'>
<Route component={App} />
</HashRouter>
然后,我的路由器:
<Switch>
<Route path='/statistics' component={Statistics}/>
<Route path='/search' component={Search}/>
<Route path='/settings' component={User}/>
<Route path='/demo' component={Demo}/>
<Route path='/' component={Statistics}/>
<Route render={() => <SiteNotFound />} />
</Switch>
每当我重新加载页面时,都会呈现“统计”组件,因为 http://localhost:8080/#/app/demo 我希望呈现演示组件,但我得到了统计组件。 有人可以解释一下这种行为吗?
谢谢
【问题讨论】:
标签: javascript reactjs routing react-router-v4