Help on loop with v-for



can someone show me how to access with v-for the properties of the objects inside every array?



I think a good bit of this depends on how you structure your template for the component. Let’s make three assumptions to help my answer along:

  1. This data is coming from an API request.
  2. is being pushed to the component’s internal data object into a property we’ll call items.
  3. You want to use an unordered list to display the data.

In this case, you’d have to nest two v-for loops like so:

  <div class="hello">
    <ul class="hello__list">
      <li v-for="item in items">
            v-for="obj in item" 
            {{ obj.propertyName }}

As you can see, the outer v-for corresponds to the top-level objects in the array, which also happen to be arrays. The inner v-for is responsible for iterating through those inner arrays.

Does this make sense?


Yes it make sense. The problem was with the way i wrote the code. Because v-for was not working when i nested <tr>.

The solution for my problem was the following:

Problem solved! Thanks for the help!


I noticed that you’re hard-coding the index of poliseis (i.e. poliseis[0]). Won’t this become a problem if you have no idea how many objects are in that array?


That’s right! But in this response laravel sending at least 1 array on every object, so i will not have a problem!