swiper基础设置

 

new Swiper(".swiper", {
          initialSlide: 1,
          centeredSlidesBounds: true,
          slidesPerView: status == "pc" ? 1.354 : 1.253,  //视图层显示的sild个数
          centeredSlides: true,   //居中幻灯片。设定为true时,当前的active slide 会居中,而不是默认状态下的居左。
          loop: true, // 循环模式选项
          loopAdditionalSlides: 6, //循环模式下虚拟slid的个数
          // autoplay: true,
          effect: "coverflow",
          grabCursor: true, //鼠标变成手掌
          resizeObserver: true,//开启后可使用浏览器的ResizeObserver API(如果浏览器支持)来监测swiper 的container 大小变化。
          coverflowEffect:
            status == "pc"
              ? {
                  rotate: 0,
                  stretch: "34%",
                  depth: 841,
                  // modifier: 2,
                  slideShadows: false,
                }
              : {
                  rotate: 0,
                  stretch: "34%",
                  depth: 500,
                  // modifier: 2,
                  slideShadows: false,
                },
          // 如果需要分页器
          pagination: {
            el: ".swiper-pagination",
            clickable: true,
          },
          // 如果需要前进后退按钮
          navigation: {
            nextEl: ".swiper-button-next",
            prevEl: ".swiper-button-prev",
          },
        });
      }

 

posted @ 2022-07-03 17:14  SimoonJia  阅读(574)  评论(0编辑  收藏  举报