Implementation of object arrays in VUE

It is actually very simple, and the general array can be used directly to use the new set () method, but the array object, complicated, can not be used directly, we can take indirect methods

  Unique (arr) {const res = new map (); return arr.filter ((arr) =>! Res.has ( && res. set (, 1)}  
There is an example in which the object’s ID is used as a basis:

quichong () {let arr = [{id: 1, name: ‘111’}, {ID: 1, Name: ‘111’}, {ID: 2, Name: ‘222’}, {ID: 3, Name: ‘333’}]; console.log (arr); console.log (‘- —————— ‘); let arr1 = this.unique (arr); console.log (arr1);}, unique (arr) {const res = new Map (); return arr.filter (arr) =>! Res.has ( && res. set (ArR.ID, 1));},
  This is very simple to weigh  
All the content of this article, I hope to help everyone, I hope everyone will support Tumi Cloud.
© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment