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