File tree 3 files changed +33
-0
lines changed
3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import React from 'react';
2
2
import { connect } from 'dva' ;
3
3
import { Switch , NavLink , routerRedux } from 'dva/router' ;
4
4
import $$ from 'cmn-utils' ;
5
+ import { Notification } from 'components' ;
5
6
import './styles/basic.less' ;
6
7
7
8
@connect ( )
@@ -26,6 +27,7 @@ export default class BasicLayout extends React.PureComponent {
26
27
< Switch >
27
28
{ childRoutes }
28
29
</ Switch >
30
+ < Notification />
29
31
</ div >
30
32
) ;
31
33
}
Original file line number Diff line number Diff line change @@ -3,10 +3,19 @@ import { connect } from 'dva';
3
3
import logo from 'assets/images/logo.png' ;
4
4
import './style.less' ;
5
5
import BaseComponent from 'components/BaseComponent' ;
6
+ import { Notification } from 'components' ;
6
7
import $$ from 'cmn-utils' ;
8
+ const notice = Notification . notice ;
7
9
8
10
@connect ( )
9
11
export default class Home extends BaseComponent {
12
+ notice = ( e ) => {
13
+ this . close = notice ( e . target . innerHTML , e . target . innerHTML ) ;
14
+ }
15
+
16
+ closeNotice = ( ) => {
17
+ this . close && this . close ( ) ;
18
+ }
10
19
11
20
render ( ) {
12
21
const user = $$ . getStore ( 'user' ) ;
@@ -15,6 +24,13 @@ export default class Home extends BaseComponent {
15
24
< div className = "home-page" >
16
25
< img src = { logo } alt = "" />
17
26
< div > Welcome Home { user . name } </ div >
27
+ < hr />
28
+ < button onClick = { this . notice } > success</ button >
29
+ < button onClick = { this . notice } > error</ button >
30
+ < button onClick = { this . notice } > warn</ button >
31
+ < button onClick = { this . notice } > default</ button >
32
+ < button onClick = { this . notice } > dark</ button >
33
+ < button onClick = { this . closeNotice } > close</ button >
18
34
</ div >
19
35
)
20
36
}
Original file line number Diff line number Diff line change @@ -46,6 +46,17 @@ export default class UserInfo extends Component {
46
46
} ) ;
47
47
}
48
48
49
+ throwRequestError = ( ) => {
50
+ this . props . dispatch ( {
51
+ type : 'userInfo/@request' ,
52
+ payload : {
53
+ valueField : 'httpbin' ,
54
+ url : 'http://httpbin.org/post' ,
55
+ method : 'GET' ,
56
+ }
57
+ } ) ;
58
+ }
59
+
49
60
render ( ) {
50
61
const { info, httpbin, pageData} = this . props . userInfo ;
51
62
const { pageNum, total, totalPages} = pageData ;
@@ -90,6 +101,10 @@ export default class UserInfo extends Component {
90
101
< button disabled = { pageNum < totalPages ? false : true } onClick = { e => this . turnPage ( ) } > 下一页</ button >
91
102
当前为第< b > { pageNum } </ b > 页,总计< b > { total } </ b > 条数据,共< b > { totalPages } </ b > 页
92
103
</ div >
104
+
105
+ < h2 > 全局异常捕获</ h2 >
106
+ < button onClick = { this . throwRequestError } > 点我生成一个异常</ button >
107
+
93
108
< PageLoading loading = { this . props . loading } />
94
109
</ div >
95
110
)
You can’t perform that action at this time.
0 commit comments