[Vuejs]-Vue-Owl-Carousel not working when using Loop

3๐Ÿ‘

You can try:

<div v-if="slides.length > 0">
<carousel>
 <img v-for="slide in slides" :src="getslide(slide)">
</carousel>
</div
๐Ÿ‘คWebvi Viet nam

1๐Ÿ‘

Are you using axios to get data to the slides array from the database?. If so the template of vue is being rendered before the data is received in the array causing the carousel not to work. you can re render the vue component and it will work. I had same problem and re-rendering the vue solved it.

0๐Ÿ‘

<div v-if="slides.length > 0">
<carousel>
 <img v-for="slide in slides" :src="getslide(slide)">
</carousel>
</div

code worked for me ๐Ÿ™‚

๐Ÿ‘คimotD

0๐Ÿ‘

I had the same problem, just check if your slides data is true

try this code :

<carousel v-if="slides">
   <img v-for="slide in slides" :src="slide.png">
</carousel>

Leave a comment