[Vuejs]-Vue.js reactivity not working for object array

0👍

You should try like this:

html .. 
<div v-if="a && a.arr" v-for="k in a.arr">
  {{k.name}}
</div>

data()
{
  return {
   a: {
     arr: [],
   }
  };
} 
methods:
{
 updateA(){
   a.arr=[];
   a.arr.push({name:'abc'});
 },

 updateA2(){ 
   let b = a.arr && a.arr[0];
   if(b){
    this.$set(b,'name','xyz');
   }
 }

}

Leave a comment