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实现图像LBP特征提取的操作方法

《使用Python实现图像LBP特征提取的操作方法》LBP特征叫做局部二值模式,常用于纹理特征提取,并在纹理分类中具有较强的区分能力,本文给大家介绍了如何使用Python实现图像LBP特征提取的操作方... 目录一、LBP特征介绍二、LBP特征描述三、一些改进版本的LBP1.圆形LBP算子2.旋转不变的LB

Maven的使用和配置国内源的保姆级教程

《Maven的使用和配置国内源的保姆级教程》Maven是⼀个项目管理工具,基于POM(ProjectObjectModel,项目对象模型)的概念,Maven可以通过一小段描述信息来管理项目的构建,报告... 目录1. 什么是Maven?2.创建⼀个Maven项目3.Maven 核心功能4.使用Maven H

Python中__init__方法使用的深度解析

《Python中__init__方法使用的深度解析》在Python的面向对象编程(OOP)体系中,__init__方法如同建造房屋时的奠基仪式——它定义了对象诞生时的初始状态,下面我们就来深入了解下_... 目录一、__init__的基因图谱二、初始化过程的魔法时刻继承链中的初始化顺序self参数的奥秘默认

SpringBoot使用GZIP压缩反回数据问题

《SpringBoot使用GZIP压缩反回数据问题》:本文主要介绍SpringBoot使用GZIP压缩反回数据问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录SpringBoot使用GZIP压缩反回数据1、初识gzip2、gzip是什么,可以干什么?3、Spr

HTML5中的Microdata与历史记录管理详解

《HTML5中的Microdata与历史记录管理详解》Microdata作为HTML5新增的一个特性,它允许开发者在HTML文档中添加更多的语义信息,以便于搜索引擎和浏览器更好地理解页面内容,本文将探... 目录html5中的Mijscrodata与历史记录管理背景简介html5中的Microdata使用M

html5的响应式布局的方法示例详解

《html5的响应式布局的方法示例详解》:本文主要介绍了HTML5中使用媒体查询和Flexbox进行响应式布局的方法,简要介绍了CSSGrid布局的基础知识和如何实现自动换行的网格布局,详细内容请阅读本文,希望能对你有所帮助... 一 使用媒体查询响应式布局        使用的参数@media这是常用的

HTML5表格语法格式详解

《HTML5表格语法格式详解》在HTML语法中,表格主要通过table、tr和td3个标签构成,本文通过实例代码讲解HTML5表格语法格式,感兴趣的朋友一起看看吧... 目录一、表格1.表格语法格式2.表格属性 3.例子二、不规则表格1.跨行2.跨列3.例子一、表格在html语法中,表格主要通过< tab

Spring Boot 集成 Quartz并使用Cron 表达式实现定时任务

《SpringBoot集成Quartz并使用Cron表达式实现定时任务》本篇文章介绍了如何在SpringBoot中集成Quartz进行定时任务调度,并通过Cron表达式控制任务... 目录前言1. 添加 Quartz 依赖2. 创建 Quartz 任务3. 配置 Quartz 任务调度4. 启动 Sprin

Linux下如何使用C++获取硬件信息

《Linux下如何使用C++获取硬件信息》这篇文章主要为大家详细介绍了如何使用C++实现获取CPU,主板,磁盘,BIOS信息等硬件信息,文中的示例代码讲解详细,感兴趣的小伙伴可以了解下... 目录方法获取CPU信息:读取"/proc/cpuinfo"文件获取磁盘信息:读取"/proc/diskstats"文

Java使用SLF4J记录不同级别日志的示例详解

《Java使用SLF4J记录不同级别日志的示例详解》SLF4J是一个简单的日志门面,它允许在运行时选择不同的日志实现,这篇文章主要为大家详细介绍了如何使用SLF4J记录不同级别日志,感兴趣的可以了解下... 目录一、SLF4J简介二、添加依赖三、配置Logback四、记录不同级别的日志五、总结一、SLF4J