滚动条自动滚动

onMounted(() => {
  let content = document.getElementById('content')
  let clientheight = content.clientHeight
  let offsetheight = content.scrollHeight
  let h = offsetheight - clientheight
  var position = 0

  function startscroll() {
    if (content.scrollTop < h) {
      position++;
      content.scrollTop = position
    }
    if (content.scrollTop >= h) {
      content.scrollTop = 0;
      position = 0
    }
  }

  setInterval(startscroll, 100)
})

滚动条自动滚动
http://xuyuanhang.com//archives/gun-dong-tiao-zi-dong-gun-dong
作者
许远航
发布于
2023年07月05日
许可协议