【发布时间】:2020-05-14 02:58:51
【问题描述】:
我有多家商店。这些商店出售各种产品。页面上应显示商店列表,以及商店销售的产品类别列表。
Console.log data in coming but I can't display Store product Category pare list
<template>
<div class="store">
<div v-for="store in stores" :key="store.id" :set="products = getProducts(store.id)">
<h2>{{store.name}}</h2>
//Other Store info
<ul>
<li v-for="product in products">
{{product.category.name}}
//This data is not Show
</li>
</ul>
</div>
</div>
</template>
<script>
export default {
data() {
return {
stores: []
}
},
mounted() {
var app = this;
axios.get('/axios/allstore/')
.then(function (response) {
app.stores = response.data;
console.log(response.data);
})
.catch(function (error) {
console.log(error);
});
},
methods: {
getProducts(storeID) {
var pp = this;
axios.get('/axios/storeproducts/' + storeID, {
params: {
storeID: storeID,
}
})
.then(function (response) {
console.log(response.data);
return response.data;
})
.catch(function (error) {
console.log(error);
});
}
},
}
</script>
谢谢,前进。
【问题讨论】:
-
你的代码有什么问题?
-
另外,我们是否应该猜测数组中的对象的外观? ;) 请发布示例数据。
-
我没有。商店列表显示良好,但 :set 可变数据不显示。我有控制台数据显示,请参阅包含 img。
-
是的,但是数组包含什么,更具体地说,对象是什么样的?他们有什么属性?
-
在什么时候设置
products值?
标签: laravel vue.js vuejs2 vue-component