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

132
Vistas
props attributes aren't updated

on a component I'm receiving blog object through props

props: {
  blog: {
    type: Object,
    default: null,
  },
}

here I declare comments in data

  data: () => ({
    comments: [],
    // rest needed variables
  }),

and on the created method of that component I'm doing this:

    
created() {
  if (this.blog && this.blog.comments) {
    this.comments = [];
    this.$nextTick().then(() => {
      this.comments = this.$srv.myMethod(this.blog.comments);
      console.log('this.comments);
      this.$root.$emit('comments', this.blog, this.comments);
    });
  } else {
    // rest of code
  }
},

the problem here is that this.blog.comments isn't updated.

I expect to get changes whenever a change occur. any insights please ?

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

0

You are using created hook that is only executed 1 time when you create the component.

To check your prop changes you can use a watcher:

  watch: {
    blog: {
      handler(newValue) {
        // Your stuff here newValue contains the blog object updated
      },
      deep: true
    }
  }

But if you only need blog.comments maybe is better to use your prop like blogComments as array and watch only this prop instead the full object.

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