小编Sau*_*ede的帖子

嵌套路由在 React Router v6 中不起作用

我正在尝试反应路由器 v6。根据反应培训博客,我创建了路由对象并传递给useRoutes()

function SomeOtherElement() {
  return <h1>add user</h1>;
}

const routes = [
  {
    path: 'app',
    element: <DashboardLayout />,
    children: [
      { path: 'account', element: <AccountView /> },
      {
        path: 'users', element: <UserListView />, 
        children: [
          { path: 'add', element: <SomeOtherElement /> }
        ]
      },
      { path: 'dashboard', element: <DashboardView /> },
      { path: 'products', element: <ProductListView /> },
      { path: 'settings', element: <SettingsView /> },
      { path: '*', element: <Navigate to="/404" /> } …
Run Code Online (Sandbox Code Playgroud)

reactjs react-router

25
推荐指数
3
解决办法
4万
查看次数

标签 统计

react-router ×1

reactjs ×1