[Vuejs]-Reload carousel after AJAX call in Vue.js

6👍

Simply add a key attribute to your carousel component and then change its value after each AJAX call – this will make Vue to re-render the component:

<carousel :key="refresh" ...>
...
</carousel>

<script>
export default
{
  data()
  {
    return {
      refresh: 0,
      ...
    };
  },
  created()
  {
    axios.get('myAPIUrl').then((response) => {
            this.originalGames = response.data[2].items;
            this.todayHots = response.data[2].items_hot;
            this.refresh++;
        });
  }

Leave a comment