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

109
Visualizações
Vue router reload page with store data

I have a page with a lot of inputs where the user can change the details of an event and after that the user can click on the save button which would trigger the saveChanges() method which would re-render the page with the new inputs. This would be only a mock implementation for now as the backend is not ready so if there would be a full page reload the changes would disappear. I store the changes in my store.state and would like to see if there is a store.state.newEvent in my preloader if there is then the params.event should be the store.state.newEvent if not then the original event object.

data() {
  return {
    event: this.$route.params.event,
    newEvent: { ...this.$route.params.event},
    ...
  };
},

saveChanges() {
  store.setNewEvent(this.newEvent);
  this.$router
    .push({
      name: RouteNames.EventManagement.name,
      params: {
        ID: this.event.id,
      },
    });
},

my router

const routes = [
  {
    name: RouteNames.EventManagement.name,
    path: RouteNames.EventManagement.path,
    beforeEnter: async to => {
      await managementPreload.preload(to);
    },
    component: EventManagement,
  },
]

my preloader

  async preload(to) {
    store.showSpinner();

    console.log(store.state.newEvent);

    if (store.state.newEvent) {
      to.params.event= store.state.newEvent;
    } else {
      let data = await EventManagementManager.getById({
        id: to.params.ID,
      });
      to.params.event= data.event;
    }

    store.hideSpinner();

    return to;
  }

When I try to call the saveChanges() the console.log does not even get triggered so I guess the program does not get to the preloader at all.

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