-
Notifications
You must be signed in to change notification settings - Fork 1
/
Confirm.js
44 lines (38 loc) · 1.04 KB
/
Confirm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import "./Confirm.scss"
import React from 'react'
import ReactDOM from 'react-dom'
export default class Confirm extends React.Component {
static confirm(content, callback) {
var c = <Confirm onOk={callback} content={content} />
Confirm.setUpContainer()
ReactDOM.render(c, Confirm.container)
}
static setUpContainer() {
const container = document.createElement('div')
document.body.appendChild(container)
Confirm.container = container
}
constructor (props) {
super(props)
}
onOK() {
this.props.onOk()
}
onCancel() {
ReactDOM.unmountComponentAtNode(Confirm.container)
document.body.removeChild(Confirm.container)
}
render() {
return (
<div className="confirm-container">
<div>
<div className="content">{this.props.content}</div>
<div className="options clearfix" >
<button onClick={this.onOK.bind(this)}>确定</button>
<button onClick={this.onCancel.bind(this)}>取消</button>
</div>
</div>
</div>
)
}
}