I have a carousel ( http://idangero.us/swiper/ ) and I want to use it in a block with v-for. But I can not initialize the swiper in this cycle, since the list has not yet been rendered porridge turns out.

I tried this:

<div class="swiper-slide" v-for="(item, index) in items"> <div v-if="index == items.length-1 ? initSwiper() : ''"> <!-- slides --> </div> </div> 

But it still does not work. How to do right?

1 answer 1

I added setTimeout 0 in the initSwipe method like this:

 initSwiper() { setTimeout(function() { // init swiper }, 0); } 

It works, but the nextButton and prevButton buttons do not work :( How to fix it?