Adaptive height of textarea element under vue

Principle: listen for inputevents, get the sum of elements and elements, scrollHieghtand scrollTopchange 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";
        }
}
...

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325730218&siteId=291194637