@@ -28,13 +28,15 @@ class Demo extends React.Component {
28
28
super ();
29
29
this .state = {
30
30
isOpen: false ,
31
+ isOpen1: false ,
31
32
}
32
33
}
33
- onClick () {
34
- this .setState ({ isOpen : false });
34
+ onClick (field ) {
35
+ this .setState ({ [field] : false });
35
36
}
36
- handleVisibleChange (isOpen ) {
37
- this .setState ({ isOpen });
37
+
38
+ handleVisibleChange (field , isOpen ) {
39
+ this .setState ({ [field]: isOpen });
38
40
}
39
41
render () {
40
42
return (
@@ -43,15 +45,15 @@ class Demo extends React.Component {
43
45
trigger= " click"
44
46
placement= " top"
45
47
isOpen= {this .state .isOpen }
46
- onVisibleChange= {this .handleVisibleChange .bind (this )}
48
+ onVisibleChange= {this .handleVisibleChange .bind (this , ' isOpen ' )}
47
49
content= {
48
50
< Card bordered= {false } title= " Card标题" extra= {< a href= " #" > 更多< / a> } style= {{ width: 200 }}>
49
51
< div> Are you sure you want to delete these items? You won' t be able to recover them.</div>
50
52
<div style={{ display: "flex", justifyContent: "flex-end", marginTop: 15 }}>
51
- <Button size="small" onClick={this.onClick.bind(this)}>
53
+ <Button size="small" onClick={this.onClick.bind(this, ' isOpen ' )}>
52
54
Cancel
53
55
</Button>
54
- <Button type="danger" size="small" onClick={this.onClick.bind(this)}>
56
+ <Button type="danger" size="small" onClick={this.onClick.bind(this, ' isOpen ' )}>
55
57
Delete
56
58
</Button>
57
59
</div>
@@ -64,14 +66,16 @@ class Demo extends React.Component {
64
66
<Popover
65
67
trigger="click"
66
68
placement="top"
69
+ isOpen={this.state.isOpen1}
70
+ onVisibleChange={this.handleVisibleChange.bind(this, ' isOpen1' )}
67
71
content={
68
72
<Card bordered={false} title="Card标题" extra={<a href="#">更多</a>} style={{ width: 200 }}>
69
73
<div>Are you sure you want to delete these items? You won' t be able to recover them.< / div>
70
74
< div style= {{ display: " flex" , justifyContent: " flex-end" , marginTop: 15 }}>
71
- < Button size= " small" onClick= {this .onClick .bind (this )}>
75
+ < Button size= " small" onClick= {this .onClick .bind (this , ' isOpen1 ' )}>
72
76
Cancel
73
77
< / Button>
74
- < Button type= " danger" size= " small" onClick= {this .onClick .bind (this )}>
78
+ < Button type= " danger" size= " small" onClick= {this .onClick .bind (this , ' isOpen1 ' )}>
75
79
Delete
76
80
< / Button>
77
81
< / div>
0 commit comments