Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

479
Visualizações
Can't dispatch Vuex actions in router file (non .vue files) in Vue3 and Vuex 4

I really need help with this. I am not able to dispatch any actions from router index.ts file.

My store index is like this:

import { createStore } from "vuex";
import { actions } from "./actions";
import { getters } from "./getters";
import { mutations } from "./mutations";

// ...other code here for state and types etc...

export const store = createStore<State>({
  state,
  actions,
  getters,
  mutations,
});

Main.ts file has it like:

import {store} from "./store";
const app = createApp(App).use(router).use(store);
// ...other code ...

In router, I have a beforeEach In side before each if I use something like:

import { store } from "../store";
// ...other code...
router.beforeEach((to, from, next) => {
    // ...other code ...
    store.dispatch(ActionTypes.SignIn);
    // ...other code ...
}

I am getting this error [vuex] unknown action type: SignIn

Syntax is all correct I guess as it works in .vue files. Please help, let me know what I am doing wrong here. I have seen some examples for Vue 2 which work but Vue 3 and Vuex 4 not working for me. I can share more details in code if needed. Thanks in advance. If it works for me I will upvote and accept your answer :) If some can try this same scenario locally please let me know with example.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda