实现功能
使用这个控件控制swiper的自动轮播
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/a5dff35240bb2b842eb05e88b367b296.png)
实现思路
swiper官网列出了swiper方法:
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/d4f3d38b42eda72fd1ee205ea6b74d2c.png)
可以使用vue监听器监听是否勾选自动轮播这个按钮
- 如果勾选了就调用this.swiper.startAutoplay();方法
- 如果没有勾选就调用this.swiper.stopAutoplay();方法
实现代码
watch: {
isAutoChange(val) {
if (val) {
this.swiper.startAutoplay();
} else {
this.swiper.stopAutoplay();
}
}
},