title: click event on div and filter vuex data --vue.js
body: <p>I am stuck at this very point: exporting filter function and using it in vuex store. No problem'till here. Now am trying to put <code>@click</code> event on  divs. And when I click, for example. Audi the filter needs to show just "audi" And if I click "audi" again then it needs remove it from the filter. </p>
  
  <p>Here is the sandbox: <a href="https://codesandbox.io/s/filtering-bzphi" rel="nofollow noreferrer">https://codesandbox.io/s/filtering-bzphi</a></p>
  
  <p><strong>filter.js</strong></p>
  
  <pre><code>export const carFilter = car =&gt; allcars =&gt; {
        if (car.length &gt; 0) {
          if (allcars.name.includes(car)) {
            return true;
          } else {
            return false;
          }
        } else {
          return true;
        }
      };
  </code></pre>
  
  <p><strong>Store</strong></p>
  
  <pre><code>export const store = new Vuex.Store({
    state: {
      cars: [
        { name: "AUDI" },
        { name: "BMW" },
        { name: "MERCEDES" },
        { name: "HONDA" },
        { name: "TOYOTA" }
      ],
      carBrand: []
    },
    mutations: {
      updateCarsFilter(state, carBrand) {
        state.carBrand = carBrand;
      }
    },
    getters: {
      filteredCars: state =&gt; {
        return state.cars.filter(carFilter(state.carBrand));
      }
    }
  });
  </code></pre>
  
  <p>and <strong>App.js</strong></p>
  
  <pre><code>&lt;template&gt;
    &lt;div id="app"&gt;
      &lt;div class="boxes" :key="index" v-for="(item, index) in cars"&gt;{{item.name}}&lt;/div&gt;
      &lt;List/&gt;
    &lt;/div&gt;
  &lt;/template&gt;
  
  &lt;script&gt;
  import List from "./List.vue";
  export default {
    name: "App",
    components: {
      List
    },
    computed: {
      selectBrand: {
        set(val) {
          this.$store.commit("updateCarsFilter", val);
        },
        get() {
          return this.$store.state.carBrand;
        }
      },
      cars() {
        return this.$store.getters.filteredCars;
      }
    }
  };
  &lt;/script&gt;
  </code></pre>
  
  <p>I also created a sandbox for this. You can check it for better understanding. <a href="https://codesandbox.io/s/filtering-bzphi" rel="nofollow noreferrer">https://codesandbox.io/s/filtering-bzphi</a></p>