[Vuejs]-Loop through mapstate computed properties in Vuejs

0๐Ÿ‘

โœ…

I fix it by adding a method instead of referencing the title from the array:

HTML template:

  <v-list>
    <v-list-tile
            v-for="(item, index) in items"
            :key="index"
            :to="item.to"
            router>

      <v-list-tile-action>
        <v-icon>{{ item.icon }}</v-icon>
      </v-list-tile-action>

      <v-list-tile-content>
        <v-list-tile-title>

            {{ navItem(index) }}

        </v-list-tile-title>
      </v-list-tile-content>

    </v-list-tile>
  </v-list>

script:

methods: {
    navItem(id){
        if(id === 0) return this.home;
        if(id === 1) return this.orgsTxt;
        if(id === 2) return this.peopleTxt;
        if(id === 3) return this.servicesTxt;
    }
},

now everything is working just fine.

Leave a comment