Swiper 双向控制

controller参数

设置双向控制的参数,或者true使用默认设置
还需要设置control为swiper实例,控制该swiper,而不是被该swiper控制

示例

var mySwiper = new Swiper('.swiper-container', {
  controller: {
    control: [swiper1,swiper2],
    inverse: true,
    by: 'slide',
  },
  //controller: true,
});

control

设置为另外一个Swiper实例开始控制该Swiper。

示例

<script> 
var Swiper1 = new Swiper('#swiper-container1');
var Swiper2 = new Swiper('#swiper-container2',{
  controller: {
    control: Swiper1, //控制Swiper1
  },
})

Swiper1.controller.control = Swiper2;//Swiper1控制Swiper2,需要在Swiper2初始化后
Swiper2.controller.control = Swiper1;//Swiper2控制Swiper1,需要在Swiper1初始化后

var Swiper3 = new Swiper('#swiper-container3',{
  controller:{
    control: [Swiper1, Swiper2],//控制前面两个Swiper
  },
})
</script>

发表评论

电子邮件地址不会被公开。 必填项已用*标注