如何使滑动滑块响应角度

Har*_*rry 4 slider typescript swiper angular angular6

我的角度项目中有一个滑动滑块。在桌面视图中有4个项目。我希望在移动设备视图中有1个项目。检查此链接

https://stackblitz.com/edit/ngx-swiper-wrapper-demo-h9egdh?file=app/app.component.ts

演示.ts代码在这里

public slides = [
    'First slide',
    'Second slide',
    'Third slide',
    'Fourth slide',
    'Fifth slide',
    'Sixth slide'
  ];

  public type: string = 'component';

  public disabled: boolean = false;

  public config: SwiperConfigInterface = {
    direction: 'horizontal',
    slidesPerView: 4,
    keyboard: true,
    mousewheel: true,
    scrollbar: false,
    navigation: true,
    pagination: false
  };
Run Code Online (Sandbox Code Playgroud)

小智 5

您可以通过以下方式向配置JSON添加一个breakpoints属性:

public config: SwiperConfigInterface = {
    direction: 'horizontal',
    slidesPerView: 4,
    keyboard: true,
    mousewheel: true,
    scrollbar: false,
    navigation: true,
    pagination: false,
    breakpoints:{
       640:{
            slidesPerView: 1, 
           }
    }
};
Run Code Online (Sandbox Code Playgroud)

断点可以是您需要的任何大小,有关更多信息,请查看:https : //github.com/nolimits4web/Swiper/blob/master/demos/380-sensitive-breakpoints.html