如何在 Swiper JS 中使用 activeIndex,如何使第二个滑块处于活动状态,而不是第一个

How to use activeIndex in Swiper JS, how to make second slider active, not the first one

var swiper = new Swiper(".swiperEvent", { slidesPerView: "自动", centeredSlides:真, 间隔:115, 分页:{ el: ".swiper-pagination", 可点击:真实, }, 导航: { nextEl: ".swiper-button-next", prevEl: ".swiper-button-prev", }, }); }

根据文档,您可以使用 initialSlide:

https://swiperjs.com/swiper-api#param-initialSlide

var swiper = new Swiper(".swiperEvent", { 
  slidesPerView: "auto",
  centeredSlides: true,
  spaceBetween: 115,
  pagination: { el: ".swiper-pagination", clickable: true, }, 
  navigation: { nextEl: ".swiper-button-next", prevEl: ".swiper-button-prev" }, 
  initialSlide: 1 // HERE
})