当我尝试访问react-router中的嵌套路由时出错

时间:2016-10-05 16:59:56

标签: reactjs ecmascript-6 react-router

嗨我得到一个错误:

 [react-router] Location "/setup/gender" did not match any routes

我能够访问/设置,一切正常。 这是react-router代码:

ReactDOM.render(

  <Router history={browserHistory}>
    <Route path="/" component={Root}>
      <IndexRoute component={Home} />
      <Route path ="/setup">
        <IndexRoute component={Setup} />
        <Route path="/gender" component={Gender}></Route>
      </Route>
    </Route>
  </Router>,
  document.getElementById('root')
);

并在我的设置组件中:

export default class Setup extends Component {

  render() {
    return (
      <div>
        <Link to="/setup/gender">gender</Link>
        <SetupNav />
        {this.props.children}
      </div>
    )
  }
}

我有什么遗失的吗?

1 个答案:

答案 0 :(得分:0)

<Route path="/gender" component={Gender}></Route>

应该成为

<Route path="/setup/gender" component={Gender}></Route>