- A+
<textarea ref="form__input" :name="v" @input="handleInput" @focus="expansionArea" style="width: 95%;font-size: 30px;border-bottom: 0.02rem solid #f1f1f1;" v-model="user[v].jobDesc" placeholder="请输入工作职责" ></textarea>
handleInput(e) { e.target.style.height = 'auto'; e.target.style.height = e.target.scrollHeight + 'px'; document.getElementsByName('del' + e.target.name) .forEach(value => value.style.marginTop = e.target.scrollHeight + 'px'); }, expansionArea(e) { e.target.style.height = 'auto'; e.target.style.height = e.target.scrollHeight + 'px'; document.getElementsByName('del' + e.target.name) .forEach(value => value.style.marginTop = e.target.scrollHeight + 'px'); },
原文链接:https://blog.csdn.net/oceanyang520/article/details/124464615