Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

346
Vistas
NUXT Properties from Vuex are not getting updated in DOM when using async actions

For demonstration purposes, I created a small test page and store. According to the code, it should show count = 1, then 500ms later count = 2 as the store updates.

Here's my test.vue:

<template>
  <div>count = {{ count }}</div>
</template>

<script>
import { mapGetters } from "vuex";

export default {
  layout: "test",
  computed: {
    ...mapGetters({ count: "test/count" }),
  },
  mounted() {
    this.$store.dispatch("test/updateCount");
  },
};
</script>

store/test.js

export const state = () => ({
  count: 1
});

export const getters = {
  count(state) {
    return state.count;
  }
};

export const actions = {
  updateCount(context) {
    setTimeout(() => {
    context.commit("setCount", 2);
    }, 500);
  }
};

export const mutations = {
  setCount(state, value) {
    state.count = value;
  }
};

But the result is always count = 1 in DOM

In vue devtools, both vuex bindings and vuex state show count = 2, but its not updated in DOM.

However, it works if I remove the setTimeout function in actions.

Am I doing anything wrong?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I am working on a Japanese website, so I had google translations turned on during development, which was probably interfering with it. I turned it off and its working now!

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda