vue滚动条事件(获取滚动条距离底部距离)

<div  class="main" @scroll.passive="getScroll($event)" style="height:100px;overflow:auto;">
    <ul>
      <li>内容</li>
    </ul>
 </div>

.main{
  width: calc(1125vw / 11.25);
  height: 100%;
  overflow-y: scroll;
}
 
getScroll(event) {
      // 滚动条距离底部的距离scrollBottom
      let scrollBottom =
        event.target.scrollHeight -
        event.target.scrollTop -
        event.target.clientHeight;
      // if (this.finished && scrollBottom < 40) {
      //  操作
      // }
    },
posted @ 2022-03-21 15:34  阳菜  阅读(913)  评论(0)    收藏  举报