首页 > 其他分享 >滑动加载

滑动加载

时间:2022-08-30 12:22:24浏览次数:59  
标签:console log refs messageList methods customEventFun 滑动 加载

html

<div
class="message-box"
data-spy="scroll"
data-target="#navbar-example"
data-offset="0"
ref="messageList"
>
    
</div>

 js

mounted() {
    // 缓存指针
    let _this = this;
    // 注册scroll事件并监听
    this.$refs.messageList.addEventListener('scroll', () => {
      _this.customEventFun()
    });
  },
  methods: {
    //methods start
    customEventFun() {
      if ((this.$refs.messageList.scrollTop + this.$refs.messageList.clientHeight) >= this.$refs.messageList.scrollHeight) {
        console.log(this.$refs.messageList.scrollTop, "滚动高度");
        console.log(this.$refs.messageList.clientHeight, "可视区域高度");
        console.log(this.$refs.messageList.scrollHeight, "内容高度");
        this.$emit("loadData")
      }
    },
}

 

标签:console,log,refs,messageList,methods,customEventFun,滑动,加载
From: https://www.cnblogs.com/wxchun/p/16638861.html

相关文章