swiper里initialslide不生效

我设置的slidesPerView是1.2,initialslide就不生效,把slidesPerView注释掉,initialslide的设置就生效,这两个属性我都需要,请问怎么解决

慕容森
浏览 3349回答 1
1回答

小唯快跑啊

我的是这样的,问题已解决<script>&nbsp; &nbsp; var mySwiper = new Swiper('.swiper-container', {&nbsp; &nbsp; &nbsp; &nbsp; // autoplay: 5000,//可选选项,自动滑动&nbsp; &nbsp; &nbsp; &nbsp; // loop: true,&nbsp; &nbsp; &nbsp; &nbsp; initialSlide: 0,&nbsp; &nbsp; &nbsp; &nbsp; slidesPerView: 4,&nbsp; &nbsp; &nbsp; &nbsp; observer: true,&nbsp; &nbsp; &nbsp; &nbsp; observeParents: true,&nbsp; &nbsp; &nbsp; &nbsp; nextButton: '.swiper-button-next',&nbsp; &nbsp; &nbsp; &nbsp; prevButton: '.swiper-button-prev',&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; })&nbsp; &nbsp; //定时&nbsp; &nbsp; setTimeout(() => {&nbsp; &nbsp; &nbsp; &nbsp; mySwiper.slideTo(0, 50, false);&nbsp; &nbsp; }, 50);</script>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript