control
设置为另外一个Swiper实例开始控制该Swiper。
control信息
- 类型:
- [Swiper Instance]
- 默认:
- null
- 举例:
- myswiper
- 启用版本:
- 4.0.0
效果演示
互相控制
Swiper1
Swiper2
使用方法示例
从Swiper7开始,容器默认类名由'.swiper-container'变更为'.swiper'。
<script>
var Swiper1 = new Swiper('#swiper1');
var Swiper2 = new Swiper('#swiper2',{
controller: {
control: Swiper1, //控制Swiper1
},
})
Swiper1.controller.control = Swiper2;//Swiper1控制Swiper2,需要在Swiper2初始化后
Swiper2.controller.control = Swiper1;//Swiper2控制Swiper1,需要在Swiper1初始化后
//控制多个
var Swiper3 = new Swiper('#swiper3',{
controller:{
control: [Swiper1, Swiper2],//控制Swiper1和Swiper2
},
})
Swiper3.controller.control = [Swiper1, Swiper2]//控制Swiper1和Swiper2,和上面效果一样
</script>
转载原创文章请注明:文章转载自:Swiper中文网 [https://www.swiper.com.cn]
本文地址:https://www.swiper.com.cn/api/controller/216.html