fix(Swipe): incorrect active swipe when children changed #7802

This commit is contained in:
chenjiahan 2020-12-27 20:16:25 +08:00
parent 1a34a6599b
commit 51cb389ef9

View File

@ -258,7 +258,7 @@ export default createComponent({
}; };
const resize = () => { const resize = () => {
initialize(activeIndicator.value); initialize(state.active);
}; };
let touchStartTime; let touchStartTime;
@ -377,9 +377,14 @@ export default createComponent({
linkChildren({ size, props, count, activeIndicator }); linkChildren({ size, props, count, activeIndicator });
watch([() => children.length, () => props.initialSwipe], () => { watch(() => props.initialSwipe, initialize);
initialize(); watch(
}); () => children.length,
() => {
const active = Math.min(children.length - 1, state.active);
initialize(active);
}
);
watch( watch(
() => props.autoplay, () => props.autoplay,