Answer the question
In order to leave comments, you need to log in
How to substitute data from ajax in Vue?
There is a page with a feedback form. The user must enter their email and message. By default, you need to substitute the email address that was used during registration, but the user should be able to change it.
<form>
<input type="text" v-model="email">
<textarea v-model="message"></textarea>
</form>
<script>
...
data() {
return {
message: '',
email: '',
}
},
watch {
'$store.state.user': function() {
this.email = this.$store.state.email;
}
},
...
</script>
<script>
...
data() {
return {
message: ''
}
},
computed() {
email() {
return this.$store.state.user.email;
}
},
...
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question