mirror of
https://github.com/youzan/vant.git
synced 2026-01-14 06:03:45 +08:00
fix(DatetimePicker): should update value after calling picker methods (#10028)
This commit is contained in:
@@ -13,7 +13,7 @@ export default createComponent({
|
||||
methods: {
|
||||
// @exposed-api
|
||||
getPicker() {
|
||||
return this.$refs.root.getPicker();
|
||||
return this.$refs.root.getProxiedPicker();
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@@ -60,27 +60,43 @@ export const TimePickerMixin = {
|
||||
if (!oldVal) {
|
||||
this.$emit('input', null);
|
||||
} else {
|
||||
this.$emit('input', val)
|
||||
this.$emit('input', val);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.updateColumnValue();
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.updateInnerValue();
|
||||
});
|
||||
},
|
||||
|
||||
methods: {
|
||||
// @exposed-api
|
||||
getPicker() {
|
||||
return this.$refs.picker;
|
||||
},
|
||||
|
||||
// https://github.com/youzan/vant/issues/10013
|
||||
getProxiedPicker() {
|
||||
const { picker } = this.$refs;
|
||||
if (picker) {
|
||||
const proxy = (fn) => (...args) => {
|
||||
picker[fn](...args);
|
||||
this.updateInnerValue();
|
||||
};
|
||||
return {
|
||||
...picker,
|
||||
setValues: proxy('setValues'),
|
||||
setIndexes: proxy('setIndexes'),
|
||||
setColumnIndex: proxy('setColumnIndex'),
|
||||
setColumnValue: proxy('setColumnValue'),
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
onConfirm() {
|
||||
this.$emit('input', this.innerValue)
|
||||
this.$emit('input', this.innerValue);
|
||||
this.$emit('confirm', this.innerValue);
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user