Vue Store Snippets - wertil/Sandbox GitHub Wiki

In Component

import {mapState} from "vuex";
import {mapActions} from "vuex";

mounted() {
   this.setWeather(this.location)
  },  
computed: {
    ...mapState(["weather"])
    ...mapState("hotels", ["filters"]), // same as:
    ...mapState({ filters: state => state.hotels.filters}),

    ...mapGetters(["getterName"]) // getters only need module name if namespaced
    ...mapGetters({getterName: "module/getterName"}) // namespaced, same as
    ...mapGetters("module", ["getterName"]), // same as:
  },
methods: {
    ...mapActions(["setWeather"]),
    ...mapActions({ actionName: "module/actionName", actionName2: "module/actionName2" }),
    ...mapActions("module, ["setWeather"]),
  }

or instead of mapAction: this.$store.dispatch("setWeather", this.location)