{{product.brand}} How to loop items in Vuex store-PHP Chinese Network Q&A
How to loop items in Vuex store
P粉513318114
P粉513318114 2023-09-11 23:38:31
0
1
536

This is my store in Vue dev tools:

This is my Vue component:

 

If I use this:

{{allProducts}}

I got all the products.

But when trying to use this loop:

{{ product.brand }}

Do not show.

Can you tell me what to do?

P粉513318114
P粉513318114

reply all (1)
P粉536909186

allProductsis an object with propertyproducts, so in order to loop over products tryproduct in allProducts.products

const app = Vue.createApp({ data() { return { allProducts: { products: [ {brand: 'aaa'}, {brand: 'bbb'} ] } }; }, }) app.mount('#demo')
 
{{ product.brand }}
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!