Commit d35ae010 authored by wacky6.AriesMBP's avatar wacky6.AriesMBP Committed by 杨奕

DatePicker: support default-value for date-range

parent 4576c72e
......@@ -153,6 +153,14 @@
import DateTable from '../basic/date-table';
import ElInput from 'element-ui/packages/input';
const calcDefaultValue = defaultValue => {
if (Array.isArray(defaultValue)) {
return new Date(defaultValue[0]);
} else {
return new Date(defaultValue);
}
};
export default {
mixins: [Locale],
......@@ -221,7 +229,7 @@
popperClass: '',
minPickerWidth: 0,
maxPickerWidth: 0,
date: new Date(),
date: this.$options.defaultValue ? calcDefaultValue(this.$options.defaultValue) : new Date(),
minDate: '',
maxDate: '',
rangeState: {
......@@ -297,6 +305,7 @@
handleClear() {
this.minDate = null;
this.maxDate = null;
this.date = this.$options.defaultValue ? calcDefaultValue(this.$options.defaultValue) : new Date();
this.handleConfirm(false);
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment