Swiper.js-链接两个滑块实例?

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

我在产品页面上有2个Slider.js实例:

var swiperProdImage = new Swiper('.swiper-productimage', { }

var swiperThumbs = new Swiper('.swiper-productthumbs', { }

我想先控制下一个/上一个滑动的第二个,但不能使slideNext()正常工作?

我在哪里错了?

swiperProdImage.on('slideNextTransitionStart', function() {

   swiperThumbs.slideNext();
   swiperThumbs.update(true);

});

swiperProdImage.on('slidePrevTransitionStart', function() { 

   swiperThumbs.slidePrev();
   swiperThumbs.update(true);

});
javascript jquery function slider swiper
1个回答
0
投票

您可以使用它来同步滑块(在初始化滑块后立即执行:)

// Assign each other controls
swiperProdImage.controller.control = swiperThumbs;
swiperThumbs.controller.control = swiperProdImage;
© www.soinside.com 2019 - 2024. All rights reserved.