如何使滑动滑块在 angular 中响应

how to make swiper slider responsive in angular

我的 angular 项目中有一个滑动滑块。 它在桌面视图中有 4 个项目。我想要移动视图中的 1 个项目。检查这个 link

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
  };

您可以将断点属性添加到配置 JSON 中:

public config: SwiperConfigInterface = {
    direction: 'horizontal',
    slidesPerView: 4,
    keyboard: true,
    mousewheel: true,
    scrollbar: false,
    navigation: true,
    pagination: false,
    breakpoints:{
       640:{
            slidesPerView: 1, 
           }
    }
};

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