DatePicker: support default-value for date-range

This commit is contained in:
wacky6.AriesMBP 2017-09-18 02:12:21 +10:00 committed by 杨奕
parent 4576c72ef8
commit d35ae01042

View File

@ -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);
},