-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathdialog.js
More file actions
42 lines (35 loc) · 758 Bytes
/
dialog.js
File metadata and controls
42 lines (35 loc) · 758 Bytes
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
import React, { Component } from 'react';
class Dialog extends Component {
constructor (props) {
super(props);
this.handleClick = this.handleClick.bind(this);
}
handleClick () {
var len = this.props.nums;
var newid = len > 0 ? len : 0;
var value = this.refs.myText.value;
if (value !== '') {
var obj = {
id: newid,
name: value,
status: 0
};
this.refs.myText.value = '';
this.props.addNewTask(obj);
}
}
render () {
return (
<div className="dialog">
<div>
<h3>Task</h3>
<input type="text" ref="myText" placeholder="你想做点什么"/>
</div>
<div>
<input type="button" value="Save Task" onClick={this.handleClick}/>
</div>
</div>
);
}
}
export default Dialog;