In Vuex, I have my mutations object as follows:
mutations: {
someMethod(){
this.someReusableCode();
},
anotherMethod(){
this.someReusableCode();
},
someReusableCode(){
...
}
}
However, I'm getting an error that someReusableCode()
isn't defined. Where is the best place to define my someReusableCode()
method so this will work?
store.js
file usingexport default {}
, and then in our main-vue.js file we're doingimport store_object from store.js' and then
let store = new Vuex.Store(store_object);. I would prefer to keep the helper methods in
store.js`. I did find that adding the helper methods outside of the object in store.js works, but not sure if this is the best idea. Any feedback on that strategy would be appreciated. – Marozik