mySwiper.addSlide(index, slides);
在指定位置增加slide。可以是HTML元素或slide数组,例
mySwiper.addSlide(1, '<div class="swiper-slide">Slide 10"</div>')
mySwiper.addSlide(1, [ '<div class="swiper-slide">Slide 10"</div>', '<div class="swiper-slide">Slide 11"</div>' ]);
mySwiper.addSlide(1, '<div class="swiper-slide">Slide 10"</div>')
mySwiper.addSlide(1, [ '<div class="swiper-slide">Slide 10"</div>', '<div class="swiper-slide">Slide 11"</div>' ]);
mySwiper.addSlide(index, slides);信息
- 类型:
- function
- 启用版本:
- 4.3.2
使用方法示例
从Swiper7开始,容器默认类名由'.swiper-container'变更为'.swiper'。
<script language="javascript">
var mySwiper = new Swiper('.swiper')
mySwiper.addSlide(1,'<div class="swiper-slide">这是一个新的slide</div>'); //在index为1的位置插入一个slide
</script>
转载原创文章请注明:文章转载自:Swiper中文网 [https://www.swiper.com.cn]
本文地址:https://www.swiper.com.cn/api/manipulation/421.html