Javascript 如何在react router 3中设置主应用程序外部的路由?

Javascript 如何在react router 3中设置主应用程序外部的路由?,javascript,reactjs,router,Javascript,Reactjs,Router,我的路由配置如下(反应路由器3): 导出默认值{ 组件:应用程序, 路径:“/”, indexRoute:{component:Login}, 儿童路线:[ { 路径:“仪表板”, getComponent(位置,cb){ 系统导入(“/组件/仪表板/仪表板”) .then(module=>cb(null,checkAuth(module.default)); } }, { //…另一条路线 }, //.. ] }React router v3配置是一个对象(而不是数组)。因此,您应该有一个根

我的路由配置如下(反应路由器3):

导出默认值{
组件:应用程序,
路径:“/”,
indexRoute:{component:Login},
儿童路线:[
{
路径:“仪表板”,
getComponent(位置,cb){
系统导入(“/组件/仪表板/仪表板”)
.then(module=>cb(null,checkAuth(module.default));
}
},
{
//…另一条路线
},
//..
]

}
React router v3
配置是一个对象(而不是数组)。因此,您应该有一个根组件,任何其他路由都是该组件的子路由。可能是以下配置将为您工作

尽量让你的应用程序尽可能简单。并使用childRoutes实现配置

...
  path: '/',
  component: Root, // Just a component which actually renders children and nothing else
  childRoutes: [{
    path: '/',
    component: App,
    childRoutes: {} //Your App components children goes here.
  }, {
    path: '/YOUR_NEW_PATH', // not a part of your App
    component: YOUR_COMPONENT, // not a child of your APP
    childRoutes: {} // If you have some childRoutes
  }]
...
您的根组件可能看起来像下面的组件

Root = (props) => <div>{props.children}</div>
Root=(props)=>{props.children}

这就是我一直在寻找的解决方案。非常感谢。但是,还有一个问题-如何在react router 4中执行相同的操作?使用react router config PackageHanks,但已经在react router 4文档中找到了解决方案:)