M
M
MSAFT2019-03-20 01:21:28
Vue.js
MSAFT, 2019-03-20 01:21:28

How to remove duplicate objects in VueJS?

There is a select:

<option v-for="profile in profiles" :value="profile.brand.name">
        {{ profile.brand.name }}
      </option>

Which produces something like the following:
BrandName
BrandName2
BrandName2
BrandName3

methods: {
      uniqueFilter: function(profile) {
        if(profile.brand.name === profile.brand.name) {
          как прописать?
        }
      }
}

How to write a filter that would produce the following:
BrandName
BrandName2
BrandName3

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-03-20
@MSAFT

Make a computed property:

computed: {
  brands() {
    return [...new Set(this.profiles.map(n => n.brand.name))];
  },
},

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question