diff --git a/src/components/date-picker/picker.vue b/src/components/date-picker/picker.vue
index 588c849f..e7d244a8 100644
--- a/src/components/date-picker/picker.vue
+++ b/src/components/date-picker/picker.vue
@@ -359,6 +359,7 @@
this.internalValue = '';
this.value = '';
this.$emit('on-clear');
+ this.$dispatch('on-form-change', '');
},
showPicker () {
if (!this.picker) {
@@ -387,11 +388,10 @@
this.picker.$on('on-pick', (date, visible = false) => {
if (!this.confirm) this.visible = visible;
-
- this.emitChange(date);
this.value = date;
this.picker.value = date;
this.picker.resetView && this.picker.resetView();
+ this.emitChange(date);
});
this.picker.$on('on-pick-clear', () => {
@@ -424,6 +424,7 @@
}
this.$emit('on-change', newDate);
+ this.$dispatch('on-form-change', newDate);
}
},
watch: {
@@ -478,6 +479,14 @@
},
ready () {
if (this.open !== null) this.visible = this.open;
+ },
+ events: {
+ 'on-form-blur' () {
+ return false;
+ },
+ 'on-form-change' () {
+ return false;
+ }
}
};
diff --git a/test/routers/date.vue b/test/routers/date.vue
index 602cab0a..41958569 100644
--- a/test/routers/date.vue
+++ b/test/routers/date.vue
@@ -1,10 +1,11 @@
+ {{value1}} -- {{ value2 }}
-
+
-
+
@@ -12,7 +13,8 @@
export default {
data () {
return {
- val: new Date
+ value1: '2016-01-01',
+ value2: ['2016-01-01', '2016-02-15']
}
}
}
diff --git a/test/routers/form.vue b/test/routers/form.vue
index c0b10b22..696159b6 100644
--- a/test/routers/form.vue
+++ b/test/routers/form.vue
@@ -63,6 +63,14 @@
+
+ {{ form.date }}
+
+
+
+ {{ form.date2 | json}}
+
+
提交
@@ -108,7 +116,9 @@
checkboxgroup: [],
select: '',
selectm: [],
- slider: [40, 50]
+ slider: [40, 50],
+ date: '',
+ date2: ''
},
rules: {
mail: [
@@ -157,6 +167,27 @@
}
}
}
+ ],
+ date: [
+ {
+ required: true
+ },
+ {
+ type: 'date'
+ }
+ ],
+ date2: [
+ {
+ type: 'array', len: 2,
+ fields: {
+ 0: {
+ type: 'date', required: true
+ },
+ 1: {
+ type: 'date', required: true
+ }
+ }
+ }
]
}
}
@@ -172,6 +203,9 @@
return false;
}
});
+ },
+ c (s) {
+ console.log(this.form.date)
}
}
};