licp
2024-05-14 2caf6c0b519300a24788b7cd8d57fb0c1f0b1a0e
src/components/tool/scroll-paging.vue
@@ -2,14 +2,14 @@
  <div class="scroll-pagination"  ref="content" @scroll="onScroll">
    <slot></slot>
    <el-button
        v-if="isLoding"
        v-show="isLoding"
        type="text"
        style="display: flex; margin: 0 auto; color: #909399"
        ><i class="el-icon-loading" style="font-size:20px"></i
      ></el-button>
    <el-button
      type="text"
      v-if="finishLoding"
      v-show="finishLoding"
      style="display: flex; margin: 0 auto; color: #909399"
      >已经没有更多啦~</el-button
    >
@@ -23,6 +23,18 @@
    finishLoding: {
      type:Boolean,
      default:false
    },
    list:{
      type:Array,
      default:()=>[]
    }
  },
  watch: {
    list:{
      deep:true,
      handler(){
        this.isLoding = false
      }
    }
  },
  data() {
@@ -32,7 +44,7 @@
  },
  created(){
    // 防抖
    this.onScroll = this.debounce(this.scrollFn,2000);
    this.onScroll = this.debounce(this.scrollFn,500);
    // 节流
    // this.onScroll = this.throttle(this.scrollFn,1000);
  },
@@ -55,8 +67,7 @@
      this.isLoding = true
      setTimeout(() => {
        this.$emit('load')
        this.isLoding = false
      }, 1000)
      }, 500)
    },
    debounce(func, delay) {
      let timer = null;