[Vuejs]-Error in render: "TypeError: Cannot read property '0' of undefined" v-for loop

1👍

Your form object in data is just an empty object, and that’s fine, if a value is undefined, then you just get undefined. But then you start to iterate over some children of the undefined (the typeIndex being 0 doesn’t exist on undefined propIndex).

It’s hard to say what’s the best solution without seeing your data and understanding desired effect, but I guess it’s safe to say that populating your form object in the data with all possible values od propIndex would fix your problem.

data () {
  return  {
    form: [
      {}, {}, {}, {}, {} // as many as the possible propIndex values you expect
    ]
  } 
} 

Leave a comment