我需要在v-for中显示当前在控制台返回undefined的项目ID: 这是代码:
<ul class="list-group-item" v-for="(st,index) in stock">
<li @click="changeMenu(st)">{{st.code}}</li>
</ul>
<script>
changeMenu(obj){
this.item_name= obj.value;
console.log(obj.value);
},
</script>
测试数据:
[ { "id": 1, "code": "m009", "description": "flavour", "has_conversions": 0, "name": "milk", "selling_tax": 16, "selling_uom": null, "stocking_uom": 1, "prices": [ { "stock_item_id": 1, "unit_conversion_id": 1, "inclusive_price": 250 } ], "stock": null, "conversions": [] }, { "id": 2, "code": "w3455", "description": "good", "has_conversions": 0, "name": "wheat", "selling_tax": 16, "selling_uom": null, "stocking_uom": 1, "prices": [ { "stock_item_id": 2, "unit_conversion_id": 1, "inclusive_price": 155 } ], "stock": null, "conversions": [] },