所有:
当我在第7课按照其官方教程时,我对React Router很新:
https://github.com/reactjs/react-router-tutorial/tree/master/lessons/07-more-nesting
路线参数如:
@H_403_7@// index.js // ... <Route path="/repos" component={Repos}> <Route path="/repos/:userName/:repoName" component={Repo}/> </Route>它开始使用@R_403_331@,我想知道:
[1] React-Router如何决定使用abosulte路径或相对路径,只是因为路径以斜杠“/”开头(我发现的一件事是:一旦我在开头添加斜线到相对路径,无论父路由是什么,路径都会变成@R_403_331@.)?
[2]有没有办法可以使用相对params路径?如果没有,那么路径为“/ repos”的父路由点是什么?
谢谢
> React路由器当前使用@R_403_331@,but they are working on relative routes
>如果你想要相对路线,看起来人们从匹配参数获取当前路线,然后为其添加路线.例如,< Route path = {match.path'/ more / stuff'} />
>如果你想要相对路线,看起来人们从匹配参数获取当前路线,然后为其添加路线.例如,< Route path = {match.path'/ more / stuff'} />
在您给出的示例中,重点是每当当前路径包含/ repos时,将会显示一些内容(由component = {Repos}生成的repos链接列表).当路径为/ repos /:userName /:repoName时,它将继续显示该内容,因为路径仍匹配/ repos,但它也将显示特定repo的内容(component = {Repo}).