[bugfix] DatetimePicker: 修复动态更新minDate时未更新数据

fix #1718
This commit is contained in:
rex 2019-06-24 19:56:51 +08:00 committed by GitHub
parent 723cebac1a
commit 01ffc40686
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,24 +90,30 @@ VantComponent({
}, },
watch: { watch: {
value(val: any) { value: 'updateValue',
type: 'updateValue',
minDate: 'updateValue',
maxDate: 'updateValue',
minHour: 'updateValue',
maxHour: 'updateValue',
minMinute: 'updateValue',
maxMinute: 'updateValue'
},
methods: {
updateValue() {
const { data } = this; const { data } = this;
val = this.correctValue(val); const val = this.correctValue(this.data.value);
const isEqual = val === data.innerValue; const isEqual = val === data.innerValue;
if (!isEqual) { if (!isEqual) {
this.updateColumnValue(val).then(() => { this.updateColumnValue(val).then(() => {
this.$emit('input', val); this.$emit('input', val);
}); });
} else {
this.updateColumns();
} }
}, },
type: 'updateColumns',
minHour: 'updateColumns',
maxHour: 'updateColumns',
minMinute: 'updateColumns',
maxMinute: 'updateColumns'
},
methods: {
getPicker() { getPicker() {
if (this.picker == null) { if (this.picker == null) {
const picker = (this.picker = this.selectComponent( const picker = (this.picker = this.selectComponent(
@ -193,7 +199,7 @@ VantComponent({
return result; return result;
}, },
correctValue(value) { correctValue(value: any) {
const { data } = this; const { data } = this;
// validate value // validate value
const isDateType = data.type !== 'time'; const isDateType = data.type !== 'time';