I have a web app written in vue in which the user has to submit an amount. I want to create an integer variable total_amount that updates at each run. For eg, one user submits 50$, so total_amount should update to 50$, then another user submits 25$, then total_amount should update to 75$.
So, I want a variable that updates it's value at the click of a button and then I'm returning this updated value to a function on the same page.
Is there a way to achieve this on the frontend side itself, without any database or backend assistance?
data() {
return {
total_amount: 0
}
}
I initialized total_amount in this way, but the problem is that it starts from 0 at each run, so it does not add on the previous amount rather just returns the current value.