@@ -24,29 +24,30 @@ import "./index.less";
24
24
const Home = Loadable ( {
25
25
loader : ( ) => import ( /* webpackChunkName:'home' */ "../home" ) ,
26
26
loading : Loading , // 自定义的Loading动画组件
27
- timeout : 10000 // 可以设置一个超时时间(s)来应对网络慢的情况(在Loading动画组件中可以配置error信息)
27
+ timeout : 10000 , // 可以设置一个超时时间(s)来应对网络慢的情况(在Loading动画组件中可以配置error信息)
28
28
} ) ;
29
29
const Test = Loadable ( {
30
30
loader : ( ) => import ( /* webpackChunkName:'test' */ "../test" ) ,
31
- loading : Loading
31
+ loading : Loading ,
32
32
} ) ;
33
33
const TestClass = Loadable ( {
34
34
loader : ( ) => import ( /* webpackChunkName:'testclass' */ "../testclass" ) ,
35
- loading : Loading
35
+ loading : Loading ,
36
36
} ) ;
37
37
const Features = Loadable ( {
38
38
loader : ( ) => import ( /* webpackChunkName:'features' */ "../features" ) ,
39
- loading : Loading
39
+ loading : Loading ,
40
40
} ) ;
41
41
const NotFound = Loadable ( {
42
42
loader : ( ) => import ( /* webpackChunkName:'notfound' */ "../notfound" ) ,
43
- loading : Loading
43
+ loading : Loading ,
44
44
} ) ;
45
45
46
46
const history = createHistory ( ) ; // 实例化history对象
47
47
48
48
/** 组件 **/
49
- function RootRouterContainer ( props ) {
49
+ function RootRouterContainer ( props : any ) {
50
+ console . log ( "父级参数:" , props ) ;
50
51
// 在组件加载完毕后触发
51
52
useEffect ( ( ) => {
52
53
// 可以手动在此预加载指定的模块:
@@ -57,7 +58,7 @@ function RootRouterContainer(props) {
57
58
} , [ ] ) ;
58
59
59
60
/** 简单权限控制 **/
60
- function onEnter ( Component , props ) {
61
+ function onEnter ( Component : any , props : any ) {
61
62
// 例子:如果没有登录,直接跳转至login页
62
63
// if (sessionStorage.getItem('userInfo')) {
63
64
// return <Component {...props} />;
@@ -77,22 +78,10 @@ function RootRouterContainer(props) {
77
78
< div className = "boss" >
78
79
< Switch >
79
80
< Redirect exact from = "/" to = "/home" />
80
- < Route
81
- path = "/home"
82
- render = { props => onEnter ( Home , props ) }
83
- />
84
- < Route
85
- path = "/features"
86
- render = { props => onEnter ( Features , props ) }
87
- />
88
- < Route
89
- path = "/test"
90
- render = { props => onEnter ( Test , props ) }
91
- />
92
- < Route
93
- path = "/testclass"
94
- render = { props => onEnter ( TestClass , props ) }
95
- />
81
+ < Route path = "/home" render = { props => onEnter ( Home , props ) } />
82
+ < Route path = "/features" render = { props => onEnter ( Features , props ) } />
83
+ < Route path = "/test" render = { props => onEnter ( Test , props ) } />
84
+ < Route path = "/testclass" render = { props => onEnter ( TestClass , props ) } />
96
85
< Route component = { NotFound } />
97
86
</ Switch >
98
87
< Menu />
@@ -110,6 +99,6 @@ function RootRouterContainer(props) {
110
99
export default connect (
111
100
state => ( { } ) ,
112
101
dispatch => ( {
113
- actions : { }
114
- } )
102
+ actions : { } ,
103
+ } ) ,
115
104
) ( RootRouterContainer ) ;
0 commit comments