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

255
Visualizações
How to watch object in vue js?

I have object with longitude and latitude?

data(){
  return{
  center2:{lat:0,lng:0}
}

}

I am trying to watch it like this but not working

 watch:{
    "center2.lat":function (newValue, oldValue) {
     
      this.center2.lat = newValue;
    }
    , "center2.lng":function (newValue, oldValue) {
     
      this.center2.lng = newValue;
    }
    },

How I could do it?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Please consider this code example.

  1. Vue watch child property

    watch:{ 'item.someOtherProp'(newVal){ //to work with changes in "myArray" }, 'item.prop'(newVal){ //to work with changes in prop } }

  2. Vue watch object member

    watch: { item: { handler(val){ // do stuff }, deep: true } }

Also please consider this reference.https://vuejs.org/v2/api/#watch. You can deeply watch objects for changes.

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