滚动到指定位置的问题

// 垂直方向的滚动到页面的指定位置
  const el = document.getElementsByClassName('test')[0]
window.scrollTo({
          top: window.screen.availHeight - el.getBoundingClientRect().height,
          left: 0,
          behavior: 'smooth'
        })

// 让某个元素在水平方向滚动,滚动到屏幕的最右边或者最左边
   document.getElementById("scrollTab").scroll({left: screen.width,behavior:"smooth"})
原文地址:https://www.cnblogs.com/objectjj/p/15166472.html