react-router v4 遍历router后页面空白

我写的静态路由可以正常匹配,页面也会正常显示,但遍历之后点击菜单,路由会变,但页面是空白

这是写的静态路由 可以正常匹配
<Switch>
  <Route path="/index" component={User}/>
  <Route path="/admin" >
    <Switch>
      <Route path="/admin/log" component={Admin}/>
      <Route path="/admin/census" component={Census}/>
      <Route path="/admin/auth" component={SystemAuth}/>

    </Switch>
  </Route>
</Switch>

----------------------------------------------------------------------------------------------

下面的遍历方法 路由会变,页面空白
const adminRouters = [
    {
      path: '/index',
      component: User,
      title: '用户',
      icon: 'user'
    }, 
    {
      path: '/admin',
      title: '系统',
      icon: 'setting',
      childrens:[
        {
          path: '/admin/log',
          component: Log,
          title: '日志',
        }, 
        {
          path: '/admin/num',
          component: Num,
          title: '统计',
        }
      ]
    } 
]

generateRouter = (adminRouters) => {
    return (
      adminRouters.map(r => {
        if (r.childrens) {
          return (
            <Switch>
              <Route key={r.path} path={r.path} render={routeProps => {
                return (<r.component {...this.props} >
                  {this.generateRouter(r.childrens)}
                </r.component>);
              }}>
              </Route>
            </Switch>
          )
        } else {
          return (
            <Route
              key={r.path}
              path={r.path}
              exact
              render={routeProps => {
                return (<r.component {...routeProps} />);
              }}
            />
          )
        }

      })
    )
  }

render(){
    <Switch>
     {this.generateRouter(adminRouters)} //这是调用方法
     </Switch>
}


你加个 默认路由试试

{
      path: '/',
      component: User,
      title: '用户',
      icon: 'user'
    }, 


img

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632