textarea 自动检测高度换行

let dom = document.getElementById(id);
dom.addEventListener('input',function () {
     dom.style.height = dom.scrollTop + dom.scrollHeight + 'px';
});
        
dom.addEventListener('propertychange',function () {   //兼容IE
    dom.style.height = dom.scrollTop + dom.scrollHeight + 'px';
}
// 传id
function autoHeight(id){
    
    
}

先这么用着,还需要进一步优化。

原文地址:https://www.cnblogs.com/linxue/p/9455941.html