DatePicker: supports default value

default-value sets a default value when picker opens
pull/4417/head^2
wacky6.AriesMBP 2017-04-14 23:33:20 +08:00 committed by 杨奕
parent 2cc0fe6343
commit 3fe9acf294
2 changed files with 4 additions and 3 deletions

View File

@ -187,7 +187,7 @@
methods: { methods: {
handleClear() { handleClear() {
this.date = new Date(); this.date = this.$options.defaultValue ? new Date(this.$options.defaultValue) : new Date();
this.$emit('pick'); this.$emit('pick');
}, },
@ -357,7 +357,7 @@
return { return {
popperClass: '', popperClass: '',
pickerWidth: 0, pickerWidth: 0,
date: new Date(), date: this.$options.defaultValue ? new Date(this.$options.defaultValue) : new Date(),
value: '', value: '',
showTime: false, showTime: false,
selectionMode: 'day', selectionMode: 'day',

View File

@ -205,6 +205,7 @@ export default {
default: 'left' default: 'left'
}, },
value: {}, value: {},
defaultValue: {},
rangeSeparator: { rangeSeparator: {
default: ' - ' default: ' - '
}, },
@ -410,7 +411,7 @@ export default {
showPicker() { showPicker() {
if (this.$isServer) return; if (this.$isServer) return;
if (!this.picker) { if (!this.picker) {
this.panel.defaultValue = this.currentValue; this.panel.defaultValue = this.defaultValue || this.currentValue;
this.picker = new Vue(this.panel).$mount(); this.picker = new Vue(this.panel).$mount();
this.picker.popperClass = this.popperClass; this.picker.popperClass = this.popperClass;
this.popperElm = this.picker.$el; this.popperElm = this.picker.$el;