Swiper spaceBetween 无法正常工作

Swiper spaceBetween doesn't work properly

我正在尝试将 slidesPerView: 'auto'spaceBetween: 20 属性 一起使用,但 Swiper 每个视图仅显示一张幻灯片。

我想在第一张幻灯片之后显示下一张幻灯片,即使它会被文档宽度剪切。

  $(document).ready(function () {
     //initialize swiper when document ready
     var mySwiper = new Swiper('.swiper-container', {
        // Optional parameters
        loop: false,
        slidesPerView: 3,
        spaceBetween: 40,
        navigation: {
           prevEl: '.slider .prev-btn',
           nextEl: '.slider .next-btn',
        },
        breakpoints: {
           1200: {
              slidesPerView: 'auto',
              spaceBetween: 40,
           },
           830: {
              slidesPerView: 'auto',
              spaceBetween: 10, // <- doesn't work
           }
        }
     });
  });

但是每个视图只显示一张幻灯片,并忽略选项中设置的 space。

如何严格设置幻灯片之间的space?

我在使用 slidesPerView 时遇到了同样的问题:'auto' 总是只显示一张幻灯片。我的解决方案是 CSS: (codepen)

.swiper-container{
  width: 100%;
}
.swiper-wrapper {
  width: 50%;
}
.swiper-slide {
  text-align: center;
  width: auto;
}
.slide-image {
  height: 400px;
  width: auto;
}
.my-gallery figure {
  margin: 0px;
}

代替 slidesPerView:'auto',使用这个

breakpoints: {
      "@0.00": {
        slidesPerView: 1,
      },
      "@0.75": {
        slidesPerView: 2,
      },
      "@1.00": {
        slidesPerView: 3,
      },
      "@1.50": {
        slidesPerView: 4,
      },