react router 如何正确简单快速的设置404页面
文章目录
http://react-guide.github.io/...
官方文档半天打不开真是最致命的
搜了一堆试了都不行 什么加switch 加一堆都没用
官方文档终于打开了 - -
<Route path="/" component={App}>
<Route path="about" component={About}/>
<Route path="users" component={Users}>
<Route path="/user/:userId" component={User}/>
</Route>
<Route path="*" component={NoMatch}/>
</Route>
只需一行代码
<Route path="*" component={NoMatch}/>
component里填自己想要显示的默认组件就可以了
注意
要加在自己Route的最下面
要加在自己Route的最下面
要加在自己Route的最下面
<Route path="about" component={About}/>
<Route path="about" component={About}/>
<Route path="about" component={About}/>
<Route path="about" component={About}/>
<Route path="about" component={About}/>
//...
<Route path="*" component={NoMatch}/>
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论