Here is how I have implemented an email sending feature in Vue.js:
<template>
<button @click="sendMail(); $emit('close')">Send</button>
</template>
<script>
methods: {
sendMail () {
axios.post('/mail', {email: this.email});
this.$notify.make('Sent!', 'success');
},
invalidEmail () {
this.$notify.make('Invalid email format!', 'failure'):
}
}
</script>
My question is, what approach can I take to call the invalidEmail()
method whenever the input email is not in a valid format?