Swiper-双向控制

controller参数

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

示例

1
2
3
4
5
6
7
8
var mySwiper = new Swiper('.swiper-container', {
controller: {
control: [swiper1,swiper2],
inverse: true,
by: 'slide',
},
//controller: true,
});

control

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

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<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>
  • 版权声明: 本博客所有文章,未经许可,任何单位及个人不得做营利性使用!转载请标明出处!如有侵权请联系作者。
  • Copyrights © 2015-2020 翟天野

请我喝杯咖啡吧~