how to assign a dynamic parameter in an array in the computed method and mapState

thank you very much yes indeed we can not access this in mapState here is the functional solution:

data() {
    return {
    // -1 because the aftermovie index is 1 and the index in the array starts at 0
      id: this.$route.params.id - 1
    }
  },
  computed:
    mapState({
      aftermovies: (state) => state.festival.aftermovies
    }),

and finally to access the data

<template>
  <div>
    <div class="container text-center">
      <div>
        {{ aftermovies[this.id].id }}
        {{ aftermovies[this.id].name }}
        {{ aftermovies[this.id].video }}
      </div>
    </div>
  </div>
</template>

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top