diff --git a/packages/webpack-plugin/lib/runtime/components/react/mpx-swiper.tsx b/packages/webpack-plugin/lib/runtime/components/react/mpx-swiper.tsx index 8067e798b1..2dd33ec7c2 100644 --- a/packages/webpack-plugin/lib/runtime/components/react/mpx-swiper.tsx +++ b/packages/webpack-plugin/lib/runtime/components/react/mpx-swiper.tsx @@ -584,8 +584,9 @@ const SwiperWrapper = forwardRef, SwiperProps>((pr childrenLength.value = children.length if (children.length <= 1 || maxIndex < currentIndex.value) { pauseLoop() - currentIndex.value = circular ? 0 : maxIndex - offset.value = getOffset(currentIndex.value, step.value) + const nextIndex = circular ? 0 : maxIndex + currentIndex.value = nextIndex + offset.value = getOffset(nextIndex, step.value) if (autoplay && children.length > 1) { loop() } @@ -613,7 +614,9 @@ const SwiperWrapper = forwardRef, SwiperProps>((pr if (circular !== circularShared.value || patchElmNum !== patchElmNumShared.value) { circularShared.value = circular patchElmNumShared.value = patchElmNum - offset.value = getOffset(currentIndex.value, step.value) + if (children.length > 1 && currentIndex.value <= maxIndex) { + offset.value = getOffset(currentIndex.value, step.value) + } } }, [circular, patchElmNum]) const { gestureHandler } = useMemo(() => {