js
<textarea name="textarea" id="textarea" style='overflow-y: hidden;height:20px' onpropertychange="this.style.height = this.scrollHeight + 'px';" oninput="this.style.height = this.scrollHeight + 'px';"></textarea>
<script>
//拿到TextArea的DOM
var textarea=document.getElementById('textarea');
//设置高度
textarea.style.height = textarea.scrollHeight + 'px';
</script>