react-router v6嵌套路由

接收了一个新的react项目,使用的最新的React-router v6 需要定义二级下拉菜单,但是我的二级子路由没有出来
没搞明白这个嵌套的子路由怎么定义的

//routes.js
export const routes = [
  {
    key: 'DouyinTalent',
    exact: true,
    link: '/DouyinTalent',
    path: '/DouyinTalent/*',
    name: '抖音达人',
    component: DouyinTalent,
    children: [
        {
          key: 'DouyinTalent/GameRank',
          exact: true,
          link: '/DouyinTalent/GameRank',
          path: '/DouyinTalent/GameRank',
          name: '游戏榜',
          component: DouyinGameRank,
        },
     ]
 }
]

//import routes from './routes.js'
<Routes>
  {routes.map((route) => (
    <Route
      key={route.key}
      exact={route.exact}
      path={route.path}
      element={this.renderComponent(route)}
    />
  ))}
</Routes>
阅读 2.6k
1 个回答
新手上路,请多包涵

那个通配符是不是有问题。。。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题