反应路由器双重嵌套路由

编程入门 行业动态 更新时间:2024-10-26 22:16:17
本文介绍了反应路由器双重嵌套路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 <Router history={history}> <Route path="/" component={App}> <IndexRoute component={Home} /> <Route path="signin" component={skipWhenAuthHoc(SignIn)} /> <Route path="signup" component={skipWhenAuthHoc(SignUp)} /> <Route path="signout" component={SignOut} /> <Redirect from="account" to="/account/profile" /> <Route path="account"> <Route path="profile" component={UserProfile} /> <Route path="setting" component={UserSetting} /> </Route> </Route> </Router>

我的路由器设置如下,第一级路由的 url 有效(登录注册、注销).

i have my router set up like this, the url for the 1st level routes works (signin signup, signout).

但是,我使用 url 'localhost:8080/account/profile' 刷新浏览器,浏览器将为 GET localhost:8080/account/bundle 提供 404 错误.js.

However, i refresh the browser with url 'localhost:8080/account/profile', the broswer will give 404 error for GET localhost:8080/account/bundle.js.

有什么想法可能出问题了吗?

Any ideas what might be wrong?

推荐答案

如果您的意图是在用户浏览/account 时将用户路由到/account/profile,您可能需要修改路由组件.

You may want to modify your routes component if your intention is route user to /account/profile when user browse /account.

<Router history={history}> <Route path="/" component={App}> <IndexRoute component={Home} /> <Route path="signin" component={skipWhenAuthHoc(SignIn)} /> <Route path="signup" component={skipWhenAuthHoc(SignUp)} /> <Route path="signout" component={SignOut} /> <Route path="account"> <IndexRoute path="profile" component={UserProfile} /> <Route path="setting" component={UserSetting} /> </Route>

更多推荐

反应路由器双重嵌套路由

本文发布于:2023-11-25 17:13:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1630627.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:嵌套   路由   路由器

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!