滚动条自动滚动

admin
70
2023-07-05
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)
})
动物装饰