反应路由器双嵌套路由

时间:2016-05-24 06:16:21

标签: reactjs react-router

<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>

我的路由器设置如下,第1级路由的网址有效(登录注册,注销)。

但是,我使用网址'localhost:8080 / account / profile'刷新浏览器,broswer会为404提供GET http://localhost:8080/account/bundle.js错误。

任何想法可能出错?

1 个答案:

答案 0 :(得分:0)

如果您打算在用户浏览/帐户时将路线用户设置为/ account / profile,则可能需要修改路线组件。

<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>