This repository was archived by the owner on Oct 4, 2023. It is now read-only.
This repository was archived by the owner on Oct 4, 2023. It is now read-only.
Example using vuex modules #794
Open
Description
I've used Vuex before but never in this module sense. I am purely trying to use the vuex Counter that this package ships with. I've tried the following to no resolve any help would be nice.
/src/renderer/store/modules/Counter.js
const state = {
main: 0
}
const mutations = {
DECREMENT_MAIN_COUNTER (state) {
state.main--
},
INCREMENT_MAIN_COUNTER (state) {
state.main++
}
}
const actions = {
someAsyncTask ({ commit }) {
// do something async
commit('INCREMENT_MAIN_COUNTER')
}
}
export default {
state,
mutations,
actions
}
/src/renderer/views/Welcome.vue
<template lang="pug">
button(@click="test")
</template>
<script>
export default {
name: 'Welcome',
data () {
return {
}
},
methods: {
test () {
// what I expect to work
this.$store.dispatch('someAsyncTask')
// what I expected with "modules"
this.$store.dispatch('Counter.someAsyncTask')
// another attempt
this.$store.Counter.dispatch('someAsyncTask')
}
}
}
</script>
Metadata
Metadata
Assignees
Labels
No labels