Skip to content

Instantly share code, notes, and snippets.

@hightemp
Last active September 29, 2018 12:32
Show Gist options
  • Save hightemp/11b017c3f8f758fd9d9012666966c48e to your computer and use it in GitHub Desktop.
Save hightemp/11b017c3f8f758fd9d9012666966c48e to your computer and use it in GitHub Desktop.
Vue snippets

Vue snippets

Watch vuex state changes

computed: {
  doneTodosCount () {
    return this.$store.getters.doneTodosCount
  }
}

watch:{
  doneTodosCount(value) {
    console.log('My store value for 'doneTodosCount' changed to '+value);
  }
}

Computed getters doesn't work

Vue.component(
  'component-name',
  {
    // ...
    computed: {
      sValue: {
        cache: false, // add this
        get () 
        {
          // ...
        },
        set (sValue)
        {
          // ...
        }
      }
    },
    // ...
  }
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment