【发布时间】:2017-12-26 05:44:57
【问题描述】:
我的根组件主开关是这样的
<Provider store={createStoreWithMiddleware(reducers)}>
<HashRouter history={history} >
<Switch>
<Route exact path="/login" name="Login Page" component={Login}/>
<Route exact path="/register" name="Register Page" component={Register}/>
<Route exact path="/404" name="Page 404" component={Page404}/>
<Route exact path="/500" name="Page 500" component={Page500}/>
<Route path="/Console" name="Console" component={Console}/>
<Route path="/" name="Home" component={Full}/>
</Switch>
</HashRouter>
</Provider>
在Console 组件中,我定义了另一个开关,如下所示
<main className="container">
<div className="">
<Switch>
<Route path="/Create" name="Create Park" component={CreateNew} />
<Route path="/" name="Console" component={HomePage} />
</Switch>
</div>
</main>
当我访问/Console HomePage 组件时正确显示。
但是当我访问/Console/Create CreateNew 组件时不会显示,而是显示HomePage 组件。
我在这里做错了什么?我应该怎么做才能在/Console/Create 处显示CreateNew 组件
【问题讨论】:
标签: javascript reactjs react-router react-router-dom