import { createBrowserRouter } from 'react-router-dom'; import Article from '../pages/Article'; import Login from '../pages/Login'; import Layout from '../pages/Layout'; import { lazy } from 'react';

const About = lazy(() => import('../pages/Layout/About')); const Action = lazy(() => import('../pages/Layout/Action'));

const router = createBrowserRouter([ { path: '/', element: , children: [ { index: true, element: , }, { path: 'action', element: , }, ], }, { path: '/login', element: , }, { path: '/article/:id/:title', name: 'article', element:

, }, ]);

export default router;

React Router 配置:实现路由嵌套、动态路由和延迟加载

原文地址: https://www.cveoy.top/t/topic/qfFH 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录