Skip to content

Instantly share code, notes, and snippets.

@reneegyllensvaan
Last active July 6, 2018 04:30
Show Gist options
  • Save reneegyllensvaan/27bb0603de15f930e4b175d0fd7d9417 to your computer and use it in GitHub Desktop.
Save reneegyllensvaan/27bb0603de15f930e4b175d0fd7d9417 to your computer and use it in GitHub Desktop.
<template lang="pug">
textarea(ref="input" @input="changed" rows="1" style="height:1em;resize:none;" :id="id")
</template>
<script>
export default {
mounted() {
this.$refs.input.value = this.$options._renderChildren ? this.$options._renderChildren[0].text : ''
this.$refs.input.style.height = this.$refs.input.scrollHeight+'px'
},
props: [
'id',
],
methods: {
changed() {
this.$refs.input.style.height = 'auto'
this.$refs.input.style.height = this.$refs.input.scrollHeight+'px'
},
},
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment