I have the following component:
<template>
<div>
<form @submit.prevent="formSubmit()">
<input type="text" class="form-control" v-model="amount">
<button class="btn btn-primary" style="width: 100%">Buy</button>
</form>
</div>
</template>
<script>
export default {
props:{
},
computed: {
amount() {
return this.$store.getters.amount
},
},
methods: {
formSubmit() {
let currentObj = this;
console.log(this.amount)
axios.post('MY-BACKEND', {
amount: this.amount,
},
.then(function (response) {
currentObj.output = response.data;
}.bind(this))
.catch(function (error) {
currentObj.output = error;
});
},
}
}
</script>
This is a standard form with an input text field. The problem with my code is that when i input the field, the value of amount is not what i input into the field, but it is always the default value that this.$store.getters.coinBalance sets it to. So suppose that when i load the component the value of amount is 60 and i input in the field 120, the value of amount stays 60. How can i fix this?