我尝试用thumbs gallery实现Swiper,但似乎如示例所示那样不起作用。查看gif-有人知道吗?
if (el.hasAttribute('data-item-gallery')) {
swiperOptions.slidesPerView = 1;
swiperOptions.centeredSlides = true;
swiperOptions.slideToClickedSlide = true;
delete swiperOptions.breakpoints;
delete swiperOptions.spaceBetween;
}
setTimeout(() => {
swiperOptions.navigation.nextEl = `.${currentContainerInstanceClass} .swiper-button-next`;
swiperOptions.navigation.prevEl = `.${currentContainerInstanceClass} .swiper-button-prev`;
const swiper = new Swiper(`.${instanceClass}`, swiperOptions);
if (el.hasAttribute('data-item-gallery')) {
const galleryThumbs = new Swiper('.gallery-thumbs', {
centeredSlides: false,
slidesPerView: 'auto',
touchRatio: 0.2,
slideToClickedSlide: true
});
swiper.controller.control = galleryThumbs;
galleryThumbs.controller.control = swiper;
}
});