I am currently writing a template for sending an email and after the function I want to conditionally render a success or error block. For some reason it is not working. The function itself is working, however neither success or error block is rendered. Please find my code below.
Template:
<form v-if="success==null" @submit.prevent="sendEmail" >
... //form code
<input name="submit" type="submit" class="btn" value="send" />
</form>
<b-alert variant="success" v-if="success">success</b-alert>
<b-alert variant="error" v-if="!success">error</b-alert>
Function:
data() {
return {
success: null
}
},
methods: {
sendEmail: (e) => {
... // request code
.then((result) => {
this.success=true
console.log('success')
}, (error) => {
this.success=false
console.log('error')
})
}
}