vue-formulate
vue-formulate copied to clipboard
textarea
It would be nice to have an option to make textarea auto grow when you type into it.
a simple sullution:
<template>
<FormulateInput
type="textarea"
name="abstract"
input-class="resize-none"
ref="autoTextAreaHeight"
@input="autoTextAreaHeight"
/>
</template>
<script>
export default {
mounted() {
this.autoTextAreaHeight();
},
methods:{
autoTextAreaHeight() {
if (!this.$refs.autoTextAreaHeight) return;
var ele = this.$refs.autoTextAreaHeight.$el.querySelector("textarea");
ele.style.height = 'auto'
ele.style.height = (ele.scrollHeight) + 'px'
},
}
}
</script>
<style>
// tailwind css has already shiped with this class
.resize-none{
resize:none
}
</style>