由于我这里要把接口返回的日志不断地新增到textarea里,想实现自动滚动日志的效果。

1.首先定一个textarea类型的input组件

    <el-input id="textarea_id"
            type="textarea"
              :rows="20"
            placeholder="请输入内容"
            v-model="textarea" readonly="">
    </el-input>

2.每次新增内容都要调用

const textarea = document.getElementById('textarea_id');
textarea.scrollTop = textarea.scrollHeight;

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-19
  • 2022-12-23
  • 2021-12-18
相关资源
相似解决方案