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

122
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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