I have a vue component like this:
<div v-for="item in items">
<p>{{ item.name }}</p>
<p>{{ item.price }}</p>
<p>{{ item.qty }} </p>
<p>{{ totalAmount }} </p>
</div>
And a data from an api with an array of objects like this:
items: [{
name: 'item 1',
price: 2000,
qty: 2,
},
{
name: 'item 1',
price: 3000,
qty: 2,
},
{
name: 'item 1',
price: 4000,
qty: 2,
}]
I have tried {{ item.price * item.qty }} but I want that value to be used later.
I want to get the total from each array (price * qty). something like this:
[{
name: 'item 1',
price: 2000,
qty: 2,
totalAmount: 4000
},{
name: 'item 1',
price: 3000,
qty: 2,
totalAmount: 6000
},{
name: 'item 1',
price: 4000,
qty: 2,
totalAmount: 8000
}]
can anyone help me how to do this?