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;

  

posted @ 2022-10-27 11:07  zjxgdq  阅读(6)  评论(0编辑  收藏  举报