I have following code that sum price of product to existed number when user increase the quantity of product. But the issue with my code is if user decrease the amount price still gets increased.
Code
html
<el-input-number style="width: 100%;" ref="amount" v-on:change="amoutChanged($event, row)" v-model="row.amount" :min="1"></el-input-number>
script
data() {
return {
subtotal: 0,
}
},
methods: {
amoutChanged: function(event, row) {
console.log('amount row: ', row);
console.log('amount event: ', event);
// ISSUE: regardes that user increase or decrease the amount number this price gets increased
this.subtotal = parseInt(this.subtotal) + parseInt(row.price);
},
}
Console results
amount row: {barcoded: "8995078803078", …}
amount: (...)
barcode_id: (...)
barcoded: "8995078803078"
price: (...)
product: (...)
amount event: 2 // this is amount input by user
Question
How to properly increase and decrease price based on user action?

computedproperties to display the pricev-forloop or?el-input-numberhere? How do we know if+or-was clicked?v-for<tr v-for="(row, index) in serial_numbers" :key="index">