diff --git a/packages/date-picker/src/panel/time.vue b/packages/date-picker/src/panel/time.vue index 32373ad38..b0df378ed 100644 --- a/packages/date-picker/src/panel/time.vue +++ b/packages/date-picker/src/panel/time.vue @@ -81,6 +81,11 @@ selectableRange(val) { this.$refs.spinner.selectableRange = val; + }, + + date(val) { + this.currentDate = val; + this.reinitDate(); } }, @@ -157,13 +162,17 @@ const index = list.indexOf(this.selectionRange[0]); const next = (index + step + list.length) % list.length; this.$refs.spinner.emitSelectRange(mapping[next]); + }, + + reinitDate() { + this.hours = this.currentDate.getHours(); + this.minutes = this.currentDate.getMinutes(); + this.seconds = this.currentDate.getSeconds(); } }, created() { - this.hours = this.currentDate.getHours(); - this.minutes = this.currentDate.getMinutes(); - this.seconds = this.currentDate.getSeconds(); + this.reinitDate(); }, mounted() { diff --git a/packages/date-picker/src/picker.vue b/packages/date-picker/src/picker.vue index 8f573d39c..cf6ff0fcf 100644 --- a/packages/date-picker/src/picker.vue +++ b/packages/date-picker/src/picker.vue @@ -34,6 +34,7 @@ import Popper from 'element-ui/src/utils/vue-popper'; import Emitter from 'element-ui/src/mixins/emitter'; import Focus from 'element-ui/src/mixins/focus'; import ElInput from 'element-ui/packages/input'; +import merge from 'element-ui/src/utils/merge'; const NewPopper = { props: { @@ -449,8 +450,9 @@ export default { }, mountPicker() { - this.panel.defaultValue = this.defaultValue || this.currentValue; - this.picker = new Vue(this.panel).$mount(); + const defaultValue = this.defaultValue || this.currentValue; + const panel = merge({}, this.panel, { defaultValue }); + this.picker = new Vue(panel).$mount(); this.picker.popperClass = this.popperClass; this.popperElm = this.picker.$el; this.picker.width = this.reference.getBoundingClientRect().width;