From 9ef14500f3abfcc7081f8dceab8187ec835e3918 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 14 Oct 2015 18:09:28 +0800 Subject: [PATCH] Fix datepicker defaultValue, closes #391 --- components/datepicker/demo/basic.md | 2 +- components/datepicker/index.jsx | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/components/datepicker/demo/basic.md b/components/datepicker/demo/basic.md index 068b24431d..b2d724cc6f 100644 --- a/components/datepicker/demo/basic.md +++ b/components/datepicker/demo/basic.md @@ -11,6 +11,6 @@ var Datepicker = antd.Datepicker; React.render( - + , document.getElementById('components-datepicker-demo-basic')); ```` diff --git a/components/datepicker/index.jsx b/components/datepicker/index.jsx index 49368b09fe..ee7dd02752 100644 --- a/components/datepicker/index.jsx +++ b/components/datepicker/index.jsx @@ -15,7 +15,6 @@ Locale.shortMonths = ['1月', '2月', '3月', '4月', '5月', '6月', let defaultCalendarValue = new GregorianCalendar(zhCn); defaultCalendarValue.setTime(Date.now()); - function createPicker(TheCalendar) { return React.createClass({ getInitialState() { @@ -73,6 +72,11 @@ function createPicker(TheCalendar) { } else if (this.props.size === 'small') { sizeClass = ' ant-input-sm'; } + let defaultValue; + if (this.props.defaultValue) { + defaultValue = new GregorianCalendar(zhCn); + defaultValue.setTime(new Date(this.props.defaultValue).valueOf()); + } return (