]>
Commit | Line | Data |
---|---|---|
d3606149 | 1 | /* eslint no-console:0 */ |
2 | ||
3 | import 'rc-time-picker/assets/index.less'; | |
4 | ||
5 | import React from 'react'; | |
6 | import ReactDom from 'react-dom'; | |
4984ed85 | 7 | import moment from 'moment'; |
d3606149 | 8 | import TimePicker from 'rc-time-picker'; |
d3606149 | 9 | |
3ab3a128 | 10 | class App extends React.Component { |
11 | state = { | |
12 | value: moment(), | |
13 | }; | |
14 | handleValueChange = (value) => { | |
4984ed85 | 15 | console.log(value && value.format('HH:mm:ss')); |
d3606149 | 16 | this.setState({ value }); |
3ab3a128 | 17 | } |
18 | clear = () => { | |
6fc4e0e8 | 19 | this.setState({ |
20 | value: undefined, | |
21 | }); | |
3ab3a128 | 22 | } |
d3606149 | 23 | render() { |
24 | return ( | |
25 | <div> | |
4984ed85 | 26 | <TimePicker |
27 | defaultValue={this.state.value} | |
28 | onChange={this.handleValueChange} | |
29 | /> | |
30 | <TimePicker | |
31 | value={this.state.value} | |
32 | onChange={this.handleValueChange} | |
33 | /> | |
6fc4e0e8 | 34 | <button onClick={this.clear}>clear</button> |
d3606149 | 35 | </div> |
36 | ); | |
3ab3a128 | 37 | } |
38 | } | |
d3606149 | 39 | |
40 | ReactDom.render( | |
41 | <App />, | |
42 | document.getElementById('__react-content') | |
43 | ); |