我正在尝试反应路由器 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)