Created
March 22, 2021 15:17
-
-
Save jaydson/b282ed806407ba4103738452473bf765 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- CustomInput.vue --> | |
<template> | |
<label> | |
{{ label }} | |
<input type="text" :name="name" :value="value" @input="onInput" @change="onChange" /> | |
</label> | |
</template> | |
<script> | |
export default { | |
name: 'CustomInput', | |
props: { | |
label: { | |
type: String, | |
required: true, | |
}, | |
value: { | |
type: String, | |
required: true, | |
}, | |
}, | |
/* Can add validation here | |
watch: { | |
value: { | |
handler(newValue, oldValue) { | |
}, | |
}, | |
}, */ | |
computed: { | |
name() { | |
return this.label.toLowerCase(); | |
}, | |
}, | |
methods: { | |
onInput(event) { | |
// Can add validation here | |
this.$emit('input', event.target.value); | |
}, | |
onChange(event) { // Supports .lazy | |
// Can add validation here | |
this.$emit('change', event.target.value); | |
}, | |
}, | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment