【elementUi】组件el-scrollbar监控滚动事件

ElementUi的el-scrollbar组件

<el-scrollbar style="height: 50vh" ref="scrollbar">


</el-scrollbar>

 

 

写个事件来监听该组件的滚动事件

handleScroll() {
      let scrollbarEl = this.$refs.scrollbar.wrap;
      scrollbarEl.onscroll = () => {
        if (scrollbarEl.scrollTop == 0) {
          console.log("滚动到顶部了");
        }
      };
    }

 

this.$refs.scrollbar.wrap.scrollTop  为滚动条位置

 this.$refs.scrollbar.wrap.scrollHeight为滚动条高度

 

posted @ 2023-02-13 19:45  Hello霖  阅读(1974)  评论(0)    收藏  举报