I have created a table which display the product Price, Quantity, Cost, Total If quantity is changed for any product in the table row the value of total also have to update according to the formula quantity * cost. The products array contains cost and name.Everything is working fine but what i don't know is if i am changing quantity of one product all the products in v-for loop getting affected and all products quantity is changing, instead of this how can i change quantity for only updated product and I provided default quantity value as 0 for all products hence only products with more than 0 quantity i can use for my further operations
## Html Code ##
<table class="table table-striped">
<thead>
<tr>
<td>S.No#</td>
<td>Product</td>
<td>Cost</td>
<td>Quantity</td>
<td>Total</td>
</tr>
</thead>
<tbody>
<tr v-for="p in products">
<td>1</td>
<td>{{p.item}}</td>
<td>{{p.cost}}</td>
<td><input type="number" class="form-control qty-box" name="" v-model='qty'></td>
<td>{{p.cost*qty}}</td>
</tr>
</tbody>
</table>
## Vue Js code ##
<script>
export default {
name: 'app',
data () {
return {
counter:8,
qty:0,
products:[
{'item':'timber','cost':250,'id':1},
{'item':'wood','cost':240,'id':2},
{'item':'primer','cost':120,'id':3},
{'item':'plywood','cost':360,'id':4},
{'item':'marker','cost':220,'id':5},
{'item':'roughwood','cost':480,'id':6},
],
msg: 'Counter',
}
}
}
</script>