Skip to content

Instantly share code, notes, and snippets.

@jaydson
Created March 22, 2021 14:58
Show Gist options
  • Save jaydson/06126d6d6ce01982ef98ec08b58f86ff to your computer and use it in GitHub Desktop.
Save jaydson/06126d6d6ce01982ef98ec08b58f86ff to your computer and use it in GitHub Desktop.
<!-- CustomInput.vue -->
<template>
...
<p v-if="error">{{ error }}</p>
...
</template>
<script>
...
data() {
return {
error: '',
};
},
...
onInput(event) {
const value = event.target.value;
if (!value) {
this.error = 'Value should not be empty';
}
this.$emit('input', event.target.value)
}
...
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment