Skip to content

Commit dccaa6f

Browse files
committed
fixed the ContentMian
1 parent 65a3903 commit dccaa6f

2 files changed

Lines changed: 55 additions & 19 deletions

File tree

src/components/ContentMain/index.js

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,22 @@
11
import React,{Component} from 'react';
22
import {Switch,withRouter,Route} from 'react-router-dom';
33
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';
135
import NoMatch from '../../views/NoMatch';
146
import './index.css';
157
class ContentMain extends Component{
168
render(){
179
return(
1810
<div className="routeWrap">
1911
<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+
3020
</Switch>
3121
</div>
3222
)

src/router/route.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import DataChart from '../views/DataChart';
2+
import Basic from '../views/Basic';
3+
import Form from '../views/Form';
4+
import Message from '../views/Message';
5+
import Alert from '../views/Alert';
6+
import Spin from '../views/Spin';
7+
import Progress from '../views/Progress';
8+
import Checkbox from '../views/Checkbox';
9+
import Cascader from '../views/Cascader';
10+
export const routes = [
11+
{
12+
path: '/dataCount',
13+
component: DataChart
14+
},
15+
{
16+
path: '/basic',
17+
component: Basic
18+
},
19+
{
20+
path: '/form',
21+
component: Form
22+
},
23+
{
24+
path: "/alert",
25+
component: Alert
26+
},
27+
{
28+
path: '/message',
29+
component: Message
30+
},
31+
{
32+
path: '/spin',
33+
component: Spin
34+
},
35+
{
36+
path: '/progress',
37+
component: Progress
38+
},
39+
{
40+
path: '/checkbox',
41+
component: Checkbox
42+
},
43+
{
44+
path: '/cascader',
45+
component: Cascader
46+
}]

0 commit comments

Comments
 (0)