Skip to content

Instantly share code, notes, and snippets.

@nhumphrey2 nhumphrey2/baseinputtext.vue Secret
Created Dec 18, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.