我的路线设置如下: Route path="/chat/:id" component={Chat} /Route path="/chat/new" component={NewChat} / 当我去聊天/新的时候它也显示{聊天}.当我去/ chat / new时有没有办法专门给NewChat打电话? 您将使用
<Route path="/chat/:id" component={Chat} /> <Route path="/chat/new" component={NewChat} />
当我去聊天/新的时候它也显示{聊天}.当我去/ chat / new时有没有办法专门给NewChat打电话?
您将使用Switch并重新排序您的路由,因为Switch
将呈现第一个匹配的路由
<Switch> <Route path="/chat/new" component={NewChat} /> <Route path="/chat/:id" component={Chat} /> </Switch>