|
|
@ -0,0 +1,45 @@ |
|
|
|
import React, {Suspense} from "react"; |
|
|
|
import { Redirect, Route, Switch } from 'react-router-dom' |
|
|
|
import routes from './config' |
|
|
|
|
|
|
|
const RouterView = () => { |
|
|
|
// const { routes } = props
|
|
|
|
// console.log(routes)
|
|
|
|
|
|
|
|
return <Suspense fallback="loading"> |
|
|
|
<Switch> |
|
|
|
{ |
|
|
|
routes.map(route => { |
|
|
|
if (route.redirect) { |
|
|
|
return <Route key={route.path} |
|
|
|
path={route.path} |
|
|
|
exact={route.exact} |
|
|
|
> |
|
|
|
<Redirect to={route.redirect}/> |
|
|
|
</Route> |
|
|
|
} else { |
|
|
|
return <Route key={route.path} |
|
|
|
path={route.path} |
|
|
|
exact={route.exact} |
|
|
|
component={route.component} |
|
|
|
> |
|
|
|
|
|
|
|
</Route> |
|
|
|
} |
|
|
|
})} |
|
|
|
</Switch> |
|
|
|
</Suspense> |
|
|
|
|
|
|
|
|
|
|
|
// routes.map((item, index) => {
|
|
|
|
// return (
|
|
|
|
// <Routes key={item.id}>
|
|
|
|
// <Route key={index} path={item.path} />
|
|
|
|
// </Routes>
|
|
|
|
// )
|
|
|
|
// })
|
|
|
|
} |
|
|
|
|
|
|
|
export default RouterView |
|
|
|
|
|
|
|
{/* <Routes key={item.id}></Routes> */ } |