Home > Net >  Remove duplicates in for loop - vue
Remove duplicates in for loop - vue

Time:01-25

I have a problem that I use v-for on code and image but result is duplicate, how to fix? enter image description here

I'm sorry if I made you misunderstand. but you can ask me

Code

 <div v-for="n in follows" :key="n.follow_artist_Id">
     <div v-if="n.artist_id == sch.artist_id && n.sch_id == sch.sch_id">
         <div >
             ...
         </div>
     </div>
 </div>`

<div >
...
</div>

CodePudding user response:

I hope this helps you.

For example your array like this
products: ['Oculus', 'Google Glass', 'Microsoft Hololens', 'Oculus', 'Varjo']

and function for remove duplication is below

removeDuplicates () {
  this.products = [ ...new Set(this.products) ]
}
  • Related