Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

v-switch vuex store

import { mapState } from "vuex";

computed: {
    ...mapState(["settings"]),
    computedProperty: {
      get() {
        return this.settings.valueInState;
      },
      set(valuePassedThrough) { //the value is passed through the v-model automatically
        this.$store.dispatch(`storeAction`, valuePassedThrough);
      }
    }
}
 
PREVIOUS NEXT
Tagged: #vuex #store
ADD COMMENT
Topic
Name
8+6 =