html部分 序号 | 商品名称 | 商品价格 | 购买数量 | 增减操作 |
---|
{{ app.id }} | {{ app.name }} | {{ app.price }} | {{app.count }} | |
总价:${{totalPrice()}}
js部分
new Vue({el: '#app',data: {app_json: [{id: 1,name: '金苹果',price: 999,count: 1},{id: 2,name: '红苹果',price: 998,count: 1},{id: 3,name: '毒苹果',price: -99,count: 1}]},methods:{totalPrice : function(){var totalP = 0;for (var i = 0,len = this.app_json.length;i})
结果