|
1 | 1 | import React,{Component} from 'react'; |
2 | 2 | import {Switch,withRouter,Route} from 'react-router-dom'; |
3 | 3 | import PrivateRoute from '../../router/PrivateRoute'; |
4 | | -import DataChart from '../../views/DataChart'; |
5 | | -import Basic from '../../views/Basic'; |
6 | | -import Form from '../../views/Form'; |
7 | | -import Message from '../../views/Message'; |
8 | | -import Alert from '../../views/Alert'; |
9 | | -import Spin from '../../views/Spin'; |
10 | | -import Progress from '../../views/Progress'; |
11 | | -import Checkbox from '../../views/Checkbox'; |
12 | | -import Cascader from '../../views/Cascader'; |
| 4 | +import {routes} from '../../router/route'; |
13 | 5 | import NoMatch from '../../views/NoMatch'; |
14 | 6 | import './index.css'; |
15 | 7 | class ContentMain extends Component{ |
16 | 8 | render(){ |
17 | 9 | return( |
18 | 10 | <div className="routeWrap"> |
19 | 11 | <Switch> |
20 | | - <PrivateRoute path="/dataCount" exact component = {DataChart}/> |
21 | | - <PrivateRoute path="/basic" exact component = {Basic}/> |
22 | | - <PrivateRoute path="/form" exact component = {Form}/> |
23 | | - <PrivateRoute path="/alert" exact component = {Alert}/> |
24 | | - <PrivateRoute path="/message" exact component = {Message}/> |
25 | | - <PrivateRoute path="/spin" exact component = {Spin}/> |
26 | | - <PrivateRoute path="/progress" exact component = {Progress}/> |
27 | | - <PrivateRoute path="/checkbox" exact component = {Checkbox}/> |
28 | | - <PrivateRoute path="/cascader" exact component = {Cascader}/> |
29 | | - <Route component={NoMatch}/> |
| 12 | + { |
| 13 | + routes.map(item=>{ |
| 14 | + return ( |
| 15 | + item.path?<PrivateRoute path={item.path} exact component={item.component}/>:<Route component={NoMatch}/> |
| 16 | + ) |
| 17 | + }) |
| 18 | + } |
| 19 | + |
30 | 20 | </Switch> |
31 | 21 | </div> |
32 | 22 | ) |
|
0 commit comments