As mention in Vue Router documentation, we can simply use this.$router.push(‘router-name’) to get to the other component.
For some reason, i have some issues to use it in my store.js.
One of the solution i found here, where i need to exports all declaration inside app.js to other instance, then import it in my store.js.
app.js
const app = new Vue({ el: '#app', router, store }); export {app}
store.js
// import the app instance import {app} from './app' . . . //calling example app.$router.push('route-name');
Reference:
- https://stackoverflow.com/questions/40736799/how-to-navigate-using-vue-router-from-vuex-actions/53309412#53309412
- https://stackoverflow.com/questions/40767874/how-to-use-vue-router-from-vuex-state/40768840#40768840
Leave a Reply