Principle: listen for input
events, get the sum of elements and elements, scrollHieght
and scrollTop
change them dynamically.
Code:
<textarea v-on:input="autoTextAreaHeight" ></textarea>
...
methods:{
//textarea自适应高度
autoTextAreaHeight:function(e){
let o = e.target;
o.style.height = o.scrollTop + o.scrollHeight + "px";
}
}
...