查看原文

方法1

function updateScroll(){
    var element = document.getElementById("divId");
    element.scrollTop = element.scrollHeight;
}

方法2

<div class="container">
  <div class="inner">Bottom</div>
  <div class="inner">Hi</div>
  <div class="inner">Hi</div>
  <div class="inner">Hi</div>
  <div class="inner">Hi</div>
  <div class="inner">Hi</div>
  <div class="inner">Hi</div>
  <div class="inner">Hi</div>
  <div class="inner">Hi</div>
  <div class="inner">Hi</div>
  <div class="inner">Hi</div>
  <div class="inner">Hi</div>
  <div class="inner">Hi</div>
  <div class="inner">Hi</div>
  <div class="inner">Hi</div>
  <div class="inner">Hi</div>
  <div class="inner">Hi</div>
  <div class="inner">Top</div>
</div>

<style>
.container {
  height: 100px;
  overflow: auto;
  display: flex;
  flex-direction: column-reverse;
}
</style>
Logo

基于 Vue 的企业级 UI 组件库和中后台系统解决方案,为数万开发者服务。

更多推荐