如何使swiper滑块响应角度

问题描述 投票:2回答:1

我的角度项目中有一个滑块滑块。它在桌面视图中有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
  };
angular typescript slider angular6 swiper
1个回答
4
投票

您可以在配置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

© www.soinside.com 2019 - 2024. All rights reserved.