React路由--Index Route,官方文档翻译理解
强烈建议跟着Getting Start做一遍:React-router | Getting start tutorial
主要翻译自官方教程“Index Routes”:
Index routes are possibly the most difficult concept in React Router for people to understand. So if you’ve struggled before, we hope this can clarify it for you.
Index路由可能是React路由中最难理解的部分,如果你还是对Index路由一头雾水,看看下面的解释是否能帮助你。
Right now you’re probably looking at one of the invoices. Click on the “Invoices” link in the global nav of your app. Notice that the main content area goes blank! We can fix this with an “index” route.
(讲的是Getting start中的例子的部分)你可能会发现在主页点击invoices导航链接(Link)的时候,如果没有点击具体的链接,那默认展示空的;
如果想要点击时页面不为空,Index路由可以帮助你。
解释一下,目前点击Invoices链接会出现一堆具体的invoice链接: