[Vuejs]-How to loop an item from Vuex store

1👍

allProducts is object with property products, so in order to loop products try product in allProducts.products

const app = Vue.createApp({
  data() {
    return {
      allProducts: {
        products: [
          {brand: 'aaa'}, {brand: 'bbb'}
        ]
      }
    };
  },
})
app.mount('#demo')
<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
<div id="demo">
  <div v-for="product in allProducts.products">
    {{ product.brand }}
  </div>
</div>

Leave a comment