美文网首页
vue上拉加载更多

vue上拉加载更多

作者: 給我小鱼干 | 来源:发表于2018-07-30 12:01 被阅读0次
<div class="content" ref="scroll" @scroll="loadMore">
...
</div>
loadMore(){
            // 卷去的高度   当前可见区域  总高
          // 触发scroll事件 可能触发n次  先进来开一个定时器,下次触发时将上一次定时器清除掉
          clearTimeout(this.timer); // 节流
          this.timer = setTimeout(()=>{
            let {scrollTop,clientHeight,scrollHeight} = this.$refs.scroll;
            if(scrollTop+clientHeight+20>scrollHeight){
                this.getData(); // 获取更多
            }
          },60);
        },

相关文章

网友评论

      本文标题:vue上拉加载更多

      本文链接:https://www.haomeiwen.com/subject/kxtfvftx.html