Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

249
Views
Reload vue-owl-carousel after dynamic data update

Initialized a vue-owl-carousel using dynamic data

<script>

import carousel from 'vue-owl-carousel'

export default {
    components: { carousel },
}
<carousel :items="1">
    <img v-for="(img, index) in images" :src="img" :key="index">
  </carousel>


 data: function() {
    return {
      images: [
        "https://placeimg.com/200/200/any?1",
        "https://placeimg.com/200/200/any?2",
        "https://placeimg.com/200/200/any?3",
        "https://placeimg.com/200/200/any?4"
      ]
    };
  }

Removed one of images from the images array

How to update the owl carousel with new images array?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This should work with normal reactivity so im guessing the way how the carousel library is built is just sloppy. My advice is to just build your own carousel. It is really not that and can be a good learning curve.

Nevertheless if you really want to use this library, you could wrap the carousel in a template with a v-if condition. Because when deleting a entry from the images array the carousel needs to be rerendered to show its changes. You can force this by deleting and adding the component to the DOM by toggling the v-if of the template tag. A hacky solution to a problem that shouldnt exist in the first place. But something like this would work:

<template>
  <div id="app">
    <template v-if="toggle">
      <carousel :items="1">
        <template v-for="(img, index) in images">
          <img :src="img" :key="index" />
        </template>
      </carousel>
    </template>

    <button @click="deleteImage">DELETE A IMAGE</button>
  </div>
</template>

<script>
import Carousel from "vue-owl-carousel";
export default {
  name: "App",
  components: { Carousel },
  data() {
    return {
      images: [
        "https://placeimg.com/200/200/any?1",
        "https://placeimg.com/200/200/any?2",
        "https://placeimg.com/200/200/any?3",
        "https://placeimg.com/200/200/any?4",
      ],
      toggle: true,
    };
  },
  methods: {
    deleteImage() {
      this.toggle = false;
      this.images.pop();
      this.$nextTick(() => {
        this.toggle = true;
      });
    },
  },
};
</script>

Ive tested it and it works with the vue-owl-carousel library see sandbox

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!