textarea自适应

  • A+
所属分类:js vue 前端

<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

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: