From 8dea7fbe15574601d72bfff953809490d1e03f55 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 25 Dec 2015 15:34:32 +0800 Subject: [PATCH] Rollback with-time-picker demo but do not show --- .../date-picker/demo/with-time-picker.md | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 components/date-picker/demo/with-time-picker.md diff --git a/components/date-picker/demo/with-time-picker.md b/components/date-picker/demo/with-time-picker.md new file mode 100644 index 0000000000..642b88ebbd --- /dev/null +++ b/components/date-picker/demo/with-time-picker.md @@ -0,0 +1,53 @@ +# 日期时间选择二 + +- order: 4 +- hidden: true + +和 [时间选择框](/components/timepicer) 配合使用。 + +--- + +````jsx +import { DatePicker, TimePicker } from 'antd'; + +const DateTimePicker = React.createClass({ + handleChange(from, value) { + this.result = this.result || new Date(); + if (!value) { + if (from === 'date') { + this.selectedDate = false; + } else { + this.selectedTime = false; + } + return; + } + if (from === 'date') { + this.result.setFullYear(value.getFullYear()); + this.result.setMonth(value.getMonth()); + this.result.setDate(value.getDate()); + this.selectedDate = true; + } else { + this.result.setHours(value.getHours()); + this.result.setMinutes(value.getMinutes()); + this.result.setSeconds(value.getSeconds()); + this.selectedTime = true; + } + if (this.selectedDate && this.selectedTime) { + this.props.onSelect(this.result); + } + }, + render() { + return
+ + +
; + } +}); + +function onSelect(value) { + console.log('选择了时间:', value); +} + +ReactDOM.render( +, document.getElementById('components-date-picker-demo-with-time-picker')); +````