-
-
Save nhumphrey2/95180ebe6c7ddb498178365c5380e82e to your computer and use it in GitHub Desktop.
Base Input Text
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
<template> | |
<input | |
type="text" | |
class="input" | |
:value="value" | |
v-on="listeners" | |
> | |
</template> | |
<script> | |
export default { | |
props: { | |
value: { | |
type: String, | |
default: '', | |
} | |
}, | |
computed: { | |
listeners () { | |
return { | |
// Pass all component listeners directly to input | |
...this.$listeners, | |
// Override input listener to work with v-model | |
input: event => this.$emit('input', event.target.value) | |
} | |
} | |
} | |
} | |
</script> | |
<style lang="scss" scoped> | |
@import '../variables.scss'; | |
.input { | |
width: 100%; | |
padding: 8px 10px; | |
border: 1px solid $vue-blue; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment