diff --git a/packages/taro-components-react/src/components/swiper/index.tsx b/packages/taro-components-react/src/components/swiper/index.tsx index 0043ecb15c21..78dda370ebb9 100644 --- a/packages/taro-components-react/src/components/swiper/index.tsx +++ b/packages/taro-components-react/src/components/swiper/index.tsx @@ -172,7 +172,7 @@ class SwiperInner extends React.Component { } const loopAdditionalSlides = this.getLoopAdditionalSlides() - const centeredSlides = parseFloat(String(displayMultipleItems)) === 1 + const centeredSlides = displayMultipleItems === 1 && this.getNeedFixLoop() const slidesPerView = parseFloat(String(displayMultipleItems)) === 1 ? 'auto' : displayMultipleItems // eslint-disable-next-line @typescript-eslint/no-this-alias const that = this @@ -461,11 +461,7 @@ class SwiperInner extends React.Component { const defaultIndicatorActiveColor = indicatorActiveColor || '#000' const [pM, nM] = this.parseMargin() const cls = classNames(`taro-swiper-${this._id}`, className) - const sty = Object.assign({}, style) - const hasMargin = pM || nM - if (hasMargin) { - sty.overflow = 'hidden' - } + const sty = Object.assign({ overflow: 'hidden' }, style) if (this.props.full) { sty.height = '100%' } diff --git a/packages/taro-components/__tests__/__snapshots__/swiper.spec.tsx.snap b/packages/taro-components/__tests__/__snapshots__/swiper.spec.tsx.snap index 36334ca7ec30..57395fb93267 100644 --- a/packages/taro-components/__tests__/__snapshots__/swiper.spec.tsx.snap +++ b/packages/taro-components/__tests__/__snapshots__/swiper.spec.tsx.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Swiper events 1`] = ` - +