[Vuejs]-How get the data from an array like this with axiosjs

0👍

You can use v-for to render lists. In your case you have a nested array so you would need to do it twice. However I think you should change your data element ‘lists’ and remove all the excess quotes (“”) so it looks like this:

lists: [
  {
    name: "Destacados",
    tags: [
      "Aguila",
    ],
    isRoot: true,
    products: [
      {
      name: "Coors",
      code: 139017,
      },
      {
      name: "Bud",
      code: 139019,
      }
    ],
  }
]

and then run your v-for loops:

<template>
  <div v-for="list in lists" :key="list.name">
    <ul v-for="product in list.products :key="product.name">
      <li>{{product.name}}</li>
      <li>{{product.code}}</li>
    </ul>
  </div>
</template>

Leave a comment