D
D
danilr2019-06-16 18:07:02
JavaScript
danilr, 2019-06-16 18:07:02

How to add the item all to the filter?

How to write a filter? here they helped me with the filter, but how to correctly add "all" to the array of filters, so that when you click on everything, the rest of the filters are reset and vice versa, when you click on any other, the all button goes out

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-06-16
@danilr

You can make a computed property with a setter:

computed: {
  all: {
    get() {
      return this.filters.every(n => n.active);
    },
    set(val) {
      this.filters.forEach(n => n.active = val);
    },
  },
},

<label>
  <input type="checkbox" v-model="all">
  ALL
</label>

https://jsfiddle.net/c3b91erk/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question