2015-05-29 21:07:46 +08:00
|
|
|
# 时间选择
|
|
|
|
|
|
|
|
- order: 4
|
2015-06-02 17:20:02 +08:00
|
|
|
|
2015-11-19 14:28:54 +08:00
|
|
|
和 [时间选择组件](/components/timepicker) 配合使用。
|
2015-05-29 21:07:46 +08:00
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
````jsx
|
2015-11-19 14:28:54 +08:00
|
|
|
import { Datepicker, Timepicker } from 'antd';
|
2015-05-29 21:07:46 +08:00
|
|
|
|
2015-11-19 15:37:21 +08:00
|
|
|
function onDateChange(date) {
|
2015-11-19 15:53:40 +08:00
|
|
|
console.log(date.toLocaleDateString());
|
2015-11-19 15:37:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function onTimeChange(time) {
|
2015-11-19 15:53:40 +08:00
|
|
|
console.log(time.toLocaleTimeString());
|
|
|
|
console.log('时', time.getHours());
|
|
|
|
console.log('分', time.getMinutes());
|
|
|
|
console.log('秒', time.getSeconds());
|
2015-11-19 14:28:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(<div>
|
2015-11-19 15:37:21 +08:00
|
|
|
<Datepicker onChange={onDateChange} />
|
|
|
|
<Timepicker onChange={onTimeChange} />
|
2015-11-19 14:28:54 +08:00
|
|
|
</div>, document.getElementById('components-datepicker-demo-time'));
|
2015-05-29 21:07:46 +08:00
|
|
|
````
|