Reactjs 在同一管线上嵌套多个构件

Reactjs 在同一管线上嵌套多个构件,reactjs,react-router,Reactjs,React Router,我定义了以下路线 const routes = ( <Router history={history}> <Route path='/' component={Landing}> <Route path='' component={Invitation}/> <Route path='signin' component={Signin}/> </Route> <Route pat

我定义了以下路线

const routes = (
  <Router history={history}>
    <Route path='/' component={Landing}>
      <Route path='' component={Invitation}/>
      <Route path='signin' component={Signin}/>
    </Route>
    <Route path='*' component={NoMatch}/>
  </Router>
);
const路由=(
);
我希望在访问根
/
路由时,
邀请
组件在
登录
组件中呈现,但是我没有找到不使用嵌套路由/url的方法来实现这一点


有什么想法吗?

我认为实现它的最好方法是使用IndexRoute,它也需要嵌套,但我认为它是专为您的用例设计的

const routes = (
  <Router history={history}>
    <Route path='/' component={Landing}>
      <IndexRoute component={Invitation}/>
      <Route path='signin' component={Signin}/>
    </Route>
    <Route path='*' component={NoMatch}/>
  </Router>
);
const路由=(
);
见文件: