<template>
<div class="receivable">
<div class="application-header flex-betweenCenter" @click="goBack">
<img
class="prod-header-navImg"
src="../../assets/images/icon_back.png"
alt=""
/>
<div class="font18 hy_color weightBold">登录日志</div>
<div></div>
</div>
<div class="receivable-main">
       <ul class="scroll-box" :style="{ height: clientHeight + 'px' }" v-if="is_number==1" @scroll="handleScroll($event)">
        <li class="log-ul-li" v-for="item in list" :key="item.id">
<div>
<div>{{ item.type }}</div>
<div class="log-color">{{ item.create_time }}</div>
</div>
<div>{{ item.operate }}</div>
</li>
<div class="bottom-tishi">{{loadingText}}</div>
</ul>
<div v-if="is_number == 2">
<div class="emptaype-box">
<img src="../../assets/images/empty_order.png" alt="" />
<p>暂无数据哦!~</p>
</div>
</div>
</div>
<div class="receivable-footer"></div>
</div>
</template>
<script>
import { storage } from "@/utils/storage";
export default {
name: "Receivable",
data() {
return {
is_number: 1,
p: 1,
list: [],
timer: null,
loadingText:'',
clientHeight: null
};
},
created() {this._getUserLoginLog();
this.clientHeight = +document.documentElement.clientHeight -60
},
methods: {
goBack() {
this.$router.go(-1);
},
_getUserLoginLog() {
let data = {
token: this.token,
p: 1,
};
this.$api.getUserLoginLog(data).then((res) => {
if (res.data.length > 0) {
this.list = res.data;
this.is_number = 1;
this.p++
} else {
this.is_number = 2;
}
});
},
handleScroll(e) {
//这里使用个延时加载,不然滑动屏幕的时候会不断触发方法,去计算高度,浪费性能
let that = this
clearTimeout(this.timer)
that.timer = setTimeout(function () {
let clientHeight = e.target.clientHeight;
let scrollTop = e.target.scrollTop;
let scrollHeight = e.target.scrollHeight;
console.log(clientHeight,scrollTop,scrollHeight)
if (clientHeight + scrollTop >= scrollHeight - 10) {
that.getUserLoginLogMeuns()
}
}, 500);
},
getUserLoginLogMeuns() {
this.loadingText = '加载更多'
let data = {
token: this.token,
p: this.p,
};
this.loadingText = '加载中...'
this.$api.getUserLoginLog(data).then((res) => {
if (res.data.length > 0) {
this.list = this.list.concat(res.data)
this.is_number = 1
} else if(res.data.length==0){
this.loadingText = '没有更多了'
}
this.p++
});
},
},
};
</script>

vue项目 h5上拉加载(分页功能)的更多相关文章

  1. Android 上拉加载更多功能

    前几天看了github上面的例子,参照它的实现,自己又稍微改了一点,往项目里面增加了一个上拉加载更多功能.具体的实现如下: 首先要重写ListView: import android.content. ...

  2. 你必须了解的RecyclerView的五大开源项目-解决上拉加载、下拉刷新和添加Header、Footer等问题

    前段时间做项目由于采用的MD设计,所以必须要使用RecyclerView全面代替ListView.但是开发中遇到了需要实现RecyclerView上拉加载.下拉刷新和添加Header以及Footer等 ...

  3. vue移动端上拉加载更多

    LoadMore.vue <template> <div class="load-more-wrapper" @touchstart="touchSta ...

  4. IOS tableview下拉刷新上拉加载分页

    http://code4app.com/ios/快速集成下拉上拉刷新/52326ce26803fabc46000000 刷新没用用插件,加载使用的MJ老师的插件. - (void)viewDidLoa ...

  5. h5上拉加载更多

    --------------------------------------------------------------------------例子1 <div class="bo ...

  6. Flutter移动电商实战 --(20)首页上拉加载更多功能的制作

    这节课学习一下上拉加载效果,其实现在上拉加载的插件有很多,但是还没有一个插件可以说完全一枝独秀,我也找了一个插件,这个插件的优点就是服务比较好,作者能及时回答大家的问题.我觉的选插件也是选人,人对了, ...

  7. Android 开发 上拉加载更多功能实现

    实现思维 开始之前先废话几句,Android系统没有提供上拉加载的控件,只提供了下拉刷新的SwipeRefreshLayout控件.这个控件我们就不废话,无法实现上拉刷新的功能.现在我们说说上拉加载更 ...

  8. 微信小程序上拉加载——分页

    wxml: <view class="page"> <scroll-view class="imageViewCss_1" scroll-y= ...

  9. 前端提升生产力系列三(vant3 vue3 移动端H5下拉刷新,上拉加载组件的封装)

    | 在日常的移动端开发中,经常会遇到列表的展示,以及数据量变多的情况下还会有上拉和下拉的操作.进入新公司后发现移动端好多列表,但是在看代码的时候发现,每个列表都是单独的代码,没有任何的封装,都是通过v ...

随机推荐

  1. python运行以及入门语法基础

    pycharm下载与使用 1.pycharm官网下载(直接到pycharm下载地址) http://www.jetbrains.com/pycharm/download/#section=window ...

  2. SecureCRT登录centos日常操作

    ssh登录客户端很多,个人还是习惯使用SecureCRT,非常快捷.简单.针对日常小伙伴经常咨询的常用操作简单记录如下: 建立ssh2连接,比较简单,填写服务器ip及对应的登录用户即可. 登录界面中文 ...

  3. 矩阵顺时针打印(C++)(? 为什么不能AC,9度1391)

    #include <iostream> #include <fstream> using namespace std; int a[1000][1000]; void prin ...

  4. HBase(1/5)

    HBase学习(一) 一.了解HBase 官方文档:https://hbase.apache.org/book.html 1.1 HBase概述 HBase 是一个高可靠性.高性能.面向列.可伸缩的分 ...

  5. POJ2763 Housewife Wind (树链剖分)

    差不多是模板题,不过要注意将边权转化为点权,将边的权值赋给它所连的深度较大的点. 这样操作过后,注意查询ask()的代码有所改变(见代码注释) 1 #include<cstdio> 2 # ...

  6. 使用 Apache Hudi 实现 SCD-2(渐变维度)

    数据是当今分析世界的宝贵资产. 在向最终用户提供数据时,跟踪数据在一段时间内的变化非常重要. 渐变维度 (SCD) 是随时间推移存储和管理当前和历史数据的维度. 在 SCD 的类型中,我们将特别关注类 ...

  7. 前后端代码分离开发(Vue)

  8. 如何检查“lateinit”变量是否已初始化?

    kotlin中经常会使用延迟初始化,如果要校验lateinit var 变量是否初始化.可以使用属性引用上的.isInitialized. 原文中是这样描述的:To check whether a l ...

  9. springboot整合mybatisplus遇到的错误

    完全跟着mybatis_plus官网的案例一步一步来的,但是到junit的时候突然报错 Internal Error occurred. org.junit.platform.commons.JUni ...

  10. Python基础之函数:2、globlal与nonlocal和闭包函数、装饰器、语法糖

    目录 一.global与nonlocal 1.global 2.nonlocal 二.函数名的多种用法 三.闭包函数 1.什么是闭包函数 2.闭包函数需满足的条件 3.闭包函数的作用 4.闭包函数的实 ...