I don't think that this is what a vuex.getter is meant to do.
first, as you can see in all the above examples the getter can be mapped as a computed only
<script>
import { mapGetters } from "vuex"
export default {
computed: {
...mapGetters(['someGetter'])
},
mounted() {
console.log(this.someGetter); // a computed is not a method.
}
}
</script>
and if you need it to receive arguments, what you want is a method, not a computed.
I would recommend you to used an store.action instead:
new Vuex.Store({
actions: {
someMethod({ state }, arg){
// do something with state.someValue and the arg
return someTransformationOfYourState;
}
}
})
as actions and mutations can be mapped as methods.
and you can use it like this:
<script>
import { mapActions } from "vuex"
export default {
computed: {
},
mounted() {
// now you can use someMethod with args in your component
this.someMethod('the arg');
},
methods: {
...mapActions(['someMethod'])
},
}
</script>
the first argument of an action is the store itself, so you can access the state from there. same as the dispatch and commit functions.
NOTE that an action can only recieve one paramether (payload) so if you need to send more, you will have to wrap all of them in an object or array
this.someMethod({ arg1, arg2, ...});