el-scrollbar触底加载数据

1.el-scrollbar绑定ref


         
            
              
            

2.在mounted生命周期渲染方法

  mounted() {
    this.scrollbar(); //el-scrollbar触底事件
  },

3.在methods写方法

    scrollbar() {
      this.$refs.scrollbar.handleScroll = () => {
        var wrap = this.$refs.scrollbar.wrap;
        this.$refs.scrollbar.moveY = (wrap.scrollTop * 100) / wrap.clientHeight;
        this.$refs.scrollbar.moveX = (wrap.scrollLeft * 100) / wrap.clientWidth;
        let poor = wrap.scrollHeight - wrap.clientHeight;
        if (
          poor == parseInt(wrap.scrollTop) ||
          poor == Math.ceil(wrap.scrollTop) ||
          poor == Math.floor(wrap.scrollTop)
        ) {
           console.log("已经触底了");
        }
      };
    },

你可能感兴趣的:(elementui,vue.js,javascript)