From 83d047466bb428ab1ef96c304ae5926d92485478 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 24 Nov 2015 17:25:32 +0800 Subject: [PATCH] Add datepicker and timepicer usage demo --- components/datepicker/demo/time.md | 37 +++++++++++++++++++++++++----- components/datepicker/index.md | 1 - 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/components/datepicker/demo/time.md b/components/datepicker/demo/time.md index d72c4de844..7dd481742e 100644 --- a/components/datepicker/demo/time.md +++ b/components/datepicker/demo/time.md @@ -1,15 +1,40 @@ -# 时间选择 +# 日期时间选择 - order: 4 -准确到秒的时间选择面板。 +和 [时间选择框](/components/timepicer) 配合使用。 --- ````jsx -import { Datepicker } from 'antd'; +import { Datepicker, Timepicker } from 'antd'; -ReactDOM.render( - -, document.getElementById('components-datepicker-demo-time')); +let result = new Date(); +let selectdDate, selectdTime; +function handleChange(from, value) { + if (!value) { + from === 'date' ? + (selectdDate = false) : (selectdTime = false); + return; + } + if (from === 'date') { + result.setFullYear(value.getFullYear()); + result.setMonth(value.getMonth()); + result.setDate(value.getDate()); + selectdDate = true; + } else { + result.setHours(value.getHours()); + result.setMinutes(value.getMinutes()); + result.setSeconds(value.getSeconds()); + selectdTime = true; + } + if (selectdDate && selectdTime) { + console.log('选择结果是:' + result); + } +} + +ReactDOM.render(
+ + +
, document.getElementById('components-datepicker-demo-time')); ```` diff --git a/components/datepicker/index.md b/components/datepicker/index.md index b8d8915f1d..2f12f7978e 100644 --- a/components/datepicker/index.md +++ b/components/datepicker/index.md @@ -25,7 +25,6 @@ | format | 展示的日期格式 | string | "yyyy-MM-dd" | | disabledDate | 不可选择的日期 | function | 无 | | onChange | 时间发生变化的回调,发生在用户选择时间时 | function(Date value) | 无 | -| showTime | 显示时间选择条 | boolean | false | | disabled | 禁用 | bool | false | | style | 自定义输入框样式 | object | {} | | popupStyle | 格外的弹出日历样式 | object | {} |