[Vuejs]-TypeError: Cannot read property 'details' of undefined inside foreach in Vue.js

0👍

Your inner loop is not necessary, the error comes from there, your inner loop uses the operator this that refers to the context of the first loop, which does not contain any form declared within it.
So you have to do the following

$.each(this.form.details,(key,value)=>{
    this.form.details[key].total=76776;
});

 form: new Form({
   details : [{
    name:'',

  ])
  });

or if you need the second loop, try the following

var self = this;
 $.each(this.form.details,(key,value)=>{

   $.each(self.form.details,(key1,value1)=>{
   this.form.details[key].total=76776;
   });
   });

 form: new Form({
   details : [{
    name:'',

  ])
  });

Leave a comment