mirror of
https://gitee.com/ElemeFE/element.git
synced 2024-11-30 11:17:38 +08:00
DatePicker: support default-value for date-range
This commit is contained in:
parent
4576c72ef8
commit
d35ae01042
@ -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);
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user