Home  >  Q&A  >  body text

javascript - React-router 路由嵌套问题


我的路由嵌套如上图,为什么访问#/inspection或#/report,对应组件并未加载呢?
在Overview组件this.props.chidlren是null。
React-router不可以多重嵌套吗?求教

天蓬老师天蓬老师2628 days ago737

reply all(2)I'll reply

  • 怪我咯

    怪我咯2017-04-11 12:37:37

    直接上代码吧,相信很容易看懂

        export function createRoutes() {
          return {
            path: '/',
            component: Foo,
            indexRoute: { component: Main },
            childRoutes: [
              { path: 'Start', component: Started },
              {
                path: 'Showcase',
                component: Case,
                childRoutes: [
                  { path: 'Bash', component: Bash },
                  { path: 'Comment', component: Comment },
                ],
              },
              { path: 'Blog', component: Blog },
            ],
          };
        }

    另外,再加个地址,不知道你知道不http://react-guide.github.io/...

    reply
    0
  • PHPz

    PHPz2017-04-11 12:37:37

    你的应该是#/overview/inspection吧

    reply
    0
  • Cancelreply