el-scrollbar滚动加载
阅读原文时间:2023年07月13日阅读:1

mounted() {

 监听滚动条

      this.$refs.scrollbar.wrap.addEventListener("scroll", this.scrollContent,true)

    },

scrollContent(e){

// console.log(document.getElementsByClassName('is-scrolling-left')[0].scrollTop) 获取滚动条的高度

        let poor=e.target.scrollHeight - e.target.clientHeight

        if( poor == parseInt(e.target.scrollTop) || poor == Math.ceil(e.target.scrollTop) || poor == Math.floor(e.target.scrollTop) ){

    防止多次滚动加载

            this.isLoading?'':this.addPage()

        }

      },

      getList(){

        let params={

          isPage:1,

          currentPage:this.currentPage,

          pageSize:50,

          companyId:this.searchform.companyId,

          code:this.searchform.code,

        }

        this.$http.get(maintainRecord.findMaintainOrderList, params)

          .then(response => {

            // console.log(this.maintainList,response.list)

            // this.maintainList.push(response.list)

            this.maintainList=[…this.maintainList,…response.list]

            this.searchform.total = response.total

            this.$forceUpdate()

            this.$nextTick(()=>{

              this.isLoading=false

            })

            // this.clickedIndex = null

            // this.clickedWorkIndex = null

            // this.workList = []

            // this.workForm = {}

            // this.logForm = {}

            // this.goodsList = []

            // this.contentsList = []

          })

      },

      addPage(){

        this.isLoading=true

        if(this.searchform.currentPage*this.searchform.pageSize<this.searchform.total){

          this.currentPage=this.currentPage+1

          this.getList()

        }else{

          this.isLoading=false

        }

      },