In vue-cli, how to deduplicate the parameters in json data by using the methods of v-for loop and filter Filter?

json

Mar.18,2021

Computing properties are the best, of course, the list you pull back can be deduplicated directly.

rmSome = function(arr, key) {
 let tempObj = {}
 arr.forEach(item => {
     if (tempObj[item[key]]) {
         return
     } else {
         tempObj[item[key]] = item;
     }
 })
 return Object.values(tempObj)
}
rmSome([{a:1},{a:2},{a:2}],'a')
Menu