Vue-awesome-swiper: 轮播图不能loop , 不能autoplay

Created on 29 Sep 2018  ·  10Comments  ·  Source: surmon-china/vue-awesome-swiper

<swiper :options="swiperOption"> <swiper-slide v-for="swiper in swiperImg" :key="swiper.name"> <a href="javascript:;"><img :src="swiper.img" alt=""></a> </swiper-slide> <div class="swiper-pagination" slot="pagination"></div> <div class="swiper-button-prev swiper-button-white" slot="button-prev"></div> <div class="swiper-button-next swiper-button-white" slot="button-next"></div> </swiper>
swiperOption: { slidesPerView: 1, spaceBetween: 30, loop: true, autoplay: true, pagination: { el: ".swiper-pagination", dynamicBullets: true, clickable: true }, navigation: { nextEl: ".swiper-button-next", prevEl: ".swiper-button-prev" } },
请问下。为啥我的不能循环和自动轮播啊

Swiper loop

Most helpful comment

需要在父节点加v-if="swiperImg.length > 0"

All 10 comments

跟你一样的情况,好像是for的问题,不能循环,但是我这可以自动轮播

需要在父节点加v-if="swiperImg.length > 0"

楼上正确。。。。

需要在父节点加v-if="swiperImg.length > 0"

正解

正解

差点以为这组件有bug了

楼上正解

需要在父节点加v-if="swiperImg.length > 0"

@mayday5555 为什么这样就可以了?

v4.x 解决了此问题(待实测),理论上不再需要手动维护渲染状态。

v4.x 解决了此问题(待实测),理论上不再需要手动维护渲染状态。

用了4.1.1,始终不能autoplay,loop没问题

Was this page helpful?
0 / 5 - 0 ratings