From 5c67f4efbb82b5cbb56c6f457f62e355aa91fd69 Mon Sep 17 00:00:00 2001 From: MYW Date: Fri, 19 Aug 2022 09:54:52 +0800 Subject: [PATCH] project --- src/App.js | 31 ++++---------- src/router/index.js | 63 ++++++++++------------------- src/router/{config.js => routes.js} | 6 +-- 3 files changed, 31 insertions(+), 69 deletions(-) rename src/router/{config.js => routes.js} (67%) diff --git a/src/App.js b/src/App.js index 9e23c05..37c050f 100644 --- a/src/App.js +++ b/src/App.js @@ -1,29 +1,12 @@ -import React from "react" -import { BrowserRouter, Routes, Route } from 'react-router-dom' -import RouterView from "./router/index" -import config from './router/config' - -// import Login from "./pages/login/Login" - +import React from 'react'; +import Router from './router/index'; function App() { return ( - //
- // - // - // - //
- - - - //
- // - // - // }> - // - // - //
- ) +
+ +
+ ); } -export default App \ No newline at end of file +export default App; \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index 978902e..f725df8 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,45 +1,24 @@ -import React, {Suspense} from "react"; -import { Redirect, Route, Switch } from 'react-router-dom' -import routes from './config' +import React from 'react'; +import routes from "./routes"; +import { BrowserRouter, Route, Routes } from "react-router-dom"; -const RouterView = () => { - // const { routes } = props - // console.log(routes) +function router() { + return ( + + + {routes.map((item) => { + return ( + } + /> + ); + })} + + + ); + } - return - - { - routes.map(route => { - if (route.redirect) { - return - - - } else { - return - - } - })} - - - - - // routes.map((item, index) => { - // return ( - // - // - // - // ) - // }) -} - -export default RouterView - -{/* */ } \ No newline at end of file +export default router; diff --git a/src/router/config.js b/src/router/routes.js similarity index 67% rename from src/router/config.js rename to src/router/routes.js index 45967b6..01f83c0 100644 --- a/src/router/config.js +++ b/src/router/routes.js @@ -1,7 +1,7 @@ import { lazy } from "react" -import { v4 as uuid } from 'uuid' +import { v4 as uuid} from 'uuid' -const routes = [ +const routers = [ { id: uuid(), path: '/login', @@ -9,4 +9,4 @@ const routes = [ } ] -export default routes \ No newline at end of file +export default routers \ No newline at end of file