[Vuejs]-Filter v-for array to return specific IDs only -Vue.js

2👍

well, you can do the filtering in the computed section where you are returning the items props:

 computed: {
          Items() {
            return this.items.filter((item,index)=>{return index>0 && index<5})
          }
        }

then what you will have as items is the original filtered items

1👍

Your Items property should filter that ids like :

Items() {
            return this.items.filter(item=>[1,2,3,4].includes(item.id))
          },

template :

 <div v-for="item in Items"  :item="item" :key="item.id">{{ item.name }}</div>

Leave a comment