I have discovered a workaround for accessing vue-router and other services that only works within a Vue component. By saving the "this" of the Vue app in the state of Vuex within the created option of App.vue.
Is this a good approach or could it potentially cause problems in the future?
Instead of using:
this.$router.push('route-name')
directly from a component, I am now storing the this
keyword as a key called context
in the state. Then, I use context
instead of this
in Actions like so:
state.context.router.push('route-name')
and it works.
My question is if this is a valid solution or not.