vue 使用vue-scroller 列表滑动到底部加载更多数据

本文主要是介绍vue 使用vue-scroller 列表滑动到底部加载更多数据,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

安装插件 npm install vue-scroller -dmain.js
import VueScroller from 'vue-scroller'
Vue.use(VueScroller)<template><div class="wrap"><div class="footer"><div class="btn"  @click="open = true">新增</div></div><div class="scrollerWrap"><scroller :on-infinite="infinite" ref="myscroller" :noDataText="noDataText" class="item"><div class="scrollerContent"><div class="list" v-for="(item,i) in reportRecordList" :key="i"><div class="cont">{{ item.name }}</div><div class="list-bot">          <div class="list-del" @click="handleDelete(i)">删除</div><div class="list-edit" @click="handleUpdate(i)">编辑</div></div></div></div></scroller></div><div class="mask" v-if="open"></div><div class="pop-box" v-if="open"><div class="textare-wrap"><el-input type="textarea" v-model="oname" class="otextare" resize="none"></el-input></div><div class="pop-footer"><div class="b1" @click="cancel">取消</div><div class="b2" @click="submitForm">保存</div></div></div></div>
</template>data里oname: '',// 是否显示弹出层open: false,// 用户信息user: null,// 查询参数queryParams: {pageNum: 1,pageSize: 10},total: 0,// 体测数据记录目录表格数据reportRecordList: [],noDate: false,//这是一个判断是否加载的开关noDataText: '',//目前这个还没显示出来methods里:
infinite(done) {let that = this;console.log(that.noDate)if (!that.noDate) {setTimeout(() => {          that.getList(done);}, 300)} else {this.noDataText ="无更多数据"that.$refs.myscroller.finishInfinite(true);//这个方法是不让它加载了,显示“没有更多数据”,要不然会一直转圈圈}},/** 查询体测数据记录目录列表 */getList(fn) {this.loading = true;listReportRecord(this.queryParams).then(response => {//this.reportRecordList = response.rows;let newDataList = this.reportRecordList.concat(response.rows)this.reportRecordList = newDataListthis.total = response.total;console.log("---")console.log(newDataList.length >= this.total)if (newDataList.length >= this.total) {    fn(true);      this.noDate = true} else {if(fn) fn();this.queryParams.pageNum++;//下拉一次页数+1this.noDate = false}this.loading = false;});},<style scoped>
.wrap{ min-height: 100%; background: #f8f8f8;}
.list{ margin: 0 15px 10px 15px; padding: 15px; box-sizing: border-box; background: #fff; font-size: 14px; border-radius: 10px;}
.list-bot{ margin-top: 15px; display: flex; justify-content: flex-end;}
.list-edit,.list-del{ margin-left: 15px; padding: 0 15px; height: 30px; line-height: 30px; border: 1px solid #ddd; border-radius: 15px;}
.list-del{ color: #ccc;}
.cont{ color: #333;}
.footer{ position: fixed; bottom: 0; left: 0; z-index: 99; display: flex; justify-content: center; align-items: center; width: 100%; height: 50px; background: #fff; border-top: 1px solid #f8f8f8;}
.footer .btn{ padding: 0 20px; height: 36px; line-height: 36px; background: #33a7ff; font-size: 16; color: #fff; border-radius: 18px;}.mask{ position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 998; background: rgba(0,0,0,0.3);}
.pop-box{ position: fixed; top: 50%; left: 50%; z-index: 999; transform: translate(-50%, -50%); box-sizing: border-box; width: 90%; background: #fff; border-radius: 10px;}
.pop-footer{ display: flex; height: 50px; border-top: 1px solid #f8f8f8;}
.otextare{ padding: 15px 15px 10px 15px}
.otextare /deep/ .el-textarea__inner{ height: 200px;}
.pop-footer .b1,.pop-footer .b2{ flex: 1; text-align: center; line-height: 50px; font-size: 16px; }
.pop-footer .b1{ border-right: 1px solid #f8f8f8; color: #999;}
.pop-footer .b2{ color: #33a7ff;}.scrollerWrap{position:absolute;width:100%;height: calc(100% - 70px);top: 10px;bottom: 0;    }.scrollerContent{ height: 100%;}
</style>个人记录 仅供参考

这篇关于vue 使用vue-scroller 列表滑动到底部加载更多数据的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/769130

相关文章

使用Python删除Excel中的行列和单元格示例详解

《使用Python删除Excel中的行列和单元格示例详解》在处理Excel数据时,删除不需要的行、列或单元格是一项常见且必要的操作,本文将使用Python脚本实现对Excel表格的高效自动化处理,感兴... 目录开发环境准备使用 python 删除 Excphpel 表格中的行删除特定行删除空白行删除含指定

深入理解Go语言中二维切片的使用

《深入理解Go语言中二维切片的使用》本文深入讲解了Go语言中二维切片的概念与应用,用于表示矩阵、表格等二维数据结构,文中通过示例代码介绍的非常详细,需要的朋友们下面随着小编来一起学习学习吧... 目录引言二维切片的基本概念定义创建二维切片二维切片的操作访问元素修改元素遍历二维切片二维切片的动态调整追加行动态

prometheus如何使用pushgateway监控网路丢包

《prometheus如何使用pushgateway监控网路丢包》:本文主要介绍prometheus如何使用pushgateway监控网路丢包问题,具有很好的参考价值,希望对大家有所帮助,如有错误... 目录监控网路丢包脚本数据图表总结监控网路丢包脚本[root@gtcq-gt-monitor-prome

Python通用唯一标识符模块uuid使用案例详解

《Python通用唯一标识符模块uuid使用案例详解》Pythonuuid模块用于生成128位全局唯一标识符,支持UUID1-5版本,适用于分布式系统、数据库主键等场景,需注意隐私、碰撞概率及存储优... 目录简介核心功能1. UUID版本2. UUID属性3. 命名空间使用场景1. 生成唯一标识符2. 数

浅析Spring如何控制Bean的加载顺序

《浅析Spring如何控制Bean的加载顺序》在大多数情况下,我们不需要手动控制Bean的加载顺序,因为Spring的IoC容器足够智能,但在某些特殊场景下,这种隐式的依赖关系可能不存在,下面我们就来... 目录核心原则:依赖驱动加载手动控制 Bean 加载顺序的方法方法 1:使用@DependsOn(最直

SpringBoot中如何使用Assert进行断言校验

《SpringBoot中如何使用Assert进行断言校验》Java提供了内置的assert机制,而Spring框架也提供了更强大的Assert工具类来帮助开发者进行参数校验和状态检查,下... 目录前言一、Java 原生assert简介1.1 使用方式1.2 示例代码1.3 优缺点分析二、Spring Fr

Android kotlin中 Channel 和 Flow 的区别和选择使用场景分析

《Androidkotlin中Channel和Flow的区别和选择使用场景分析》Kotlin协程中,Flow是冷数据流,按需触发,适合响应式数据处理;Channel是热数据流,持续发送,支持... 目录一、基本概念界定FlowChannel二、核心特性对比数据生产触发条件生产与消费的关系背压处理机制生命周期

java使用protobuf-maven-plugin的插件编译proto文件详解

《java使用protobuf-maven-plugin的插件编译proto文件详解》:本文主要介绍java使用protobuf-maven-plugin的插件编译proto文件,具有很好的参考价... 目录protobuf文件作为数据传输和存储的协议主要介绍在Java使用maven编译proto文件的插件

Android ClassLoader加载机制详解

《AndroidClassLoader加载机制详解》Android的ClassLoader负责加载.dex文件,基于双亲委派模型,支持热修复和插件化,需注意类冲突、内存泄漏和兼容性问题,本文给大家介... 目录一、ClassLoader概述1.1 类加载的基本概念1.2 android与Java Class

SpringBoot线程池配置使用示例详解

《SpringBoot线程池配置使用示例详解》SpringBoot集成@Async注解,支持线程池参数配置(核心数、队列容量、拒绝策略等)及生命周期管理,结合监控与任务装饰器,提升异步处理效率与系统... 目录一、核心特性二、添加依赖三、参数详解四、配置线程池五、应用实践代码说明拒绝策略(Rejected