[Vuejs]-Vuejs – access store outside of component

-1πŸ‘

It seems the way to access the store outside a component is through the state property and not from getters

This is the working code for the beforeEach router method:

router.js

import store from '@/store'

router.beforeEach(function (to, _, next) {
  const { path } = to;
  if (path !== "/signin") {
    store.state.email ? next() : next("/signin");
  } else {
    next();
  }
});

Leave a comment