react路由
/* * @Description: * @Date: 2022-10-19 21:38:20 * @Author: grab * @Copyright: (c) 2018-2022 宁波哥爱帮科技有限公司 */ import { Navigate, useRoutes } from 'react-router-dom'; import Login from '../views/login'; import About from '../pages/About'; export const rootRouter: any[] = [ { path: '/', element: <Navigate to="/login" /> }, { path: '/login', element: <Login />, meta: { requiresAuth: false, title: '登录页', key: 'login' } }, { path: '/about', element: <About />, meta: { requiresAuth: false, title: '登录页', key: 'About' } }, { path: '*', element: <Navigate to="/404" /> } ]; const Router = () => { const routes = useRoutes(rootRouter); return routes; }; export default Router;
本文来自博客园,作者:zjxgdq,转载请注明原文链接:https://www.cnblogs.com/zjxzhj/p/16831523.html