Skip to content

Instantly share code, notes, and snippets.

@nhumphrey2
Created December 18, 2018 06:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nhumphrey2/95180ebe6c7ddb498178365c5380e82e to your computer and use it in GitHub Desktop.
Save nhumphrey2/95180ebe6c7ddb498178365c5380e82e to your computer and use it in GitHub Desktop.
Base Input Text
<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