From 51cb389ef9e7581ad388ffd320b158bed21cb42c Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Sun, 27 Dec 2020 20:16:25 +0800 Subject: [PATCH] fix(Swipe): incorrect active swipe when children changed #7802 --- src/swipe/index.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/swipe/index.js b/src/swipe/index.js index 16ca44058..0d0fa213d 100644 --- a/src/swipe/index.js +++ b/src/swipe/index.js @@ -258,7 +258,7 @@ export default createComponent({ }; const resize = () => { - initialize(activeIndicator.value); + initialize(state.active); }; let touchStartTime; @@ -377,9 +377,14 @@ export default createComponent({ linkChildren({ size, props, count, activeIndicator }); - watch([() => children.length, () => props.initialSwipe], () => { - initialize(); - }); + watch(() => props.initialSwipe, initialize); + watch( + () => children.length, + () => { + const active = Math.min(children.length - 1, state.active); + initialize(active); + } + ); watch( () => props.autoplay,