Skip to content

Instantly share code, notes, and snippets.

@nickbasile
Last active July 30, 2021 02:40
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nickbasile/63c8d6ad3f29c18a1620d6b60769c548 to your computer and use it in GitHub Desktop.
Save nickbasile/63c8d6ad3f29c18a1620d6b60769c548 to your computer and use it in GitHub Desktop.
How to use a namespaced action in a Vue.js component
<template>
<div>
<button @click="increment">Increment</button>
</div>
</template>
<script>
import { mapActions } from 'vuex'
export default{
methods: {
...mapActions({
'increment': 'namespace/actionMethod'
})
}
}
</script>
@albertolo
Copy link

I have problems using VUEX namespaced modules, I have an actions and mutation types files, How I am supposed to dispatch a module/action using a const name
export const FETCH_INSTITUCIONES = 'fetchInstituciones'
Before using namespaced modules I called

this.$store.dispatch(FETCH_INSTITUCIONES)

but it doesn´t work anymore, do you know how it's gotta be?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment