您的位置:首页 > 娱乐 > 明星 > 网络运营外包托管_小黄人seo_浏览广告赚钱的平台_新公司怎么做网络推广

网络运营外包托管_小黄人seo_浏览广告赚钱的平台_新公司怎么做网络推广

2025/4/17 17:02:23 来源:https://blog.csdn.net/huangjinsheng1988/article/details/142345898  浏览:    关键词:网络运营外包托管_小黄人seo_浏览广告赚钱的平台_新公司怎么做网络推广
网络运营外包托管_小黄人seo_浏览广告赚钱的平台_新公司怎么做网络推广

自定义指令

// 表格下拉滚动加载更多
Vue.directive('loadmore', {
  bind(el, binding) {
    // 节流函数
    const throttle = (fn, wait = 300) => {
      let inThrottle, lastFn, lastTime;
      return function() {
        const context = this,
              args = arguments;
        if (!inThrottle) {
          fn.apply(context, args);
          lastTime = Date.now();
          inThrottle = true;
        } else {
          clearTimeout(lastFn);
          lastFn = setTimeout(function() {
            if (Date.now() - lastTime >= wait) {
              fn.apply(context, args);
              lastTime = Date.now();
            }
          }, Math.max(wait - (Date.now() - lastTime), 0));
        }
      };
    };

    const selectWrap = el.querySelector('.el-table__body-wrapper');
    if (selectWrap) {
      const handleScroll = throttle(function() {
        let sign = 100;
        const scrollDistance = this.scrollHeight - this.scrollTop - this.clientHeight;
        if (scrollDistance <= sign) {
          // 触发加载更多
          binding.value();
        }
      }, 300);

      // 使用passive监听器提高滚动性能
      selectWrap.addEventListener('scroll', handleScroll, { passive: true });
    }
  }
});


<el-table
                        v-loading="loading"
                        :data="rankingData"
                        v-loadmore="loadMore"
                        height="525"
                        style="width: 100%;"
                        border
                    >
                        <el-table-column
                            prop="ranking"
                            label="排名"
                            width="100"
                            align="center"
                        />
                        <el-table-column
                            prop="loginTimes"
                            label="登录次数"
                            min-width="100"
                            align="center"
                        ></el-table-column>
                    </el-table>
// 滚动加载
        loadMore() {
            if (this.total > this.rankingData.length) {
                this.query.pageNum++;
                this.getRankingList();
            }
        }


// 去除重复数据
                const dataList = data.result;
                if (dataList.length) {
                    // 使用 Set 来去重
                    const appIds = new Set(this.rankingData.map(data => data.appId));
                    const notExistData = dataList.filter(data =>
                        !appIds.has(data.appId));
                    const rankingData = [...this.rankingData, ...notExistData];
                    // 升序排列
                    this.rankingData = rankingData.sort((a, b) =>
                        a.ranking - b.ranking);
                    this.total = data.count;
                    this.showMoreHint = this.total > this.rankingData.length;
                }

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com