mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-05 05:42:44 +08:00
fix(Picker): failed to update value in some cases (#11009)
This commit is contained in:
parent
f60a3b840d
commit
0aac165d4e
@ -245,10 +245,17 @@ export default defineComponent({
|
|||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// preserve last emitted model value
|
||||||
|
// when props.modelValue is updated by parent component,
|
||||||
|
// the new value should be compared with the last emitted value
|
||||||
|
let lastEmittedModelValue: Numeric[];
|
||||||
watch(
|
watch(
|
||||||
() => props.modelValue,
|
() => props.modelValue,
|
||||||
(newValues) => {
|
(newValues) => {
|
||||||
if (!isSameValue(newValues, selectedValues.value)) {
|
if (
|
||||||
|
!isSameValue(newValues, selectedValues.value) &&
|
||||||
|
!isSameValue(newValues, lastEmittedModelValue)
|
||||||
|
) {
|
||||||
selectedValues.value = newValues.slice(0);
|
selectedValues.value = newValues.slice(0);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -258,7 +265,8 @@ export default defineComponent({
|
|||||||
selectedValues,
|
selectedValues,
|
||||||
(newValues) => {
|
(newValues) => {
|
||||||
if (!isSameValue(newValues, props.modelValue)) {
|
if (!isSameValue(newValues, props.modelValue)) {
|
||||||
emit('update:modelValue', newValues.slice(0));
|
lastEmittedModelValue = newValues.slice(0);
|
||||||
|
emit('update:modelValue', lastEmittedModelValue);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user