vuejs onclick事件在v-for循环中返回item id

时间:2018-02-24 00:28:19

标签: laravel-5 vue.js

我需要在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": [] },

0 个答案:

没有答案