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

相关文章

SQL Server修改数据库名及物理数据文件名操作步骤

《SQLServer修改数据库名及物理数据文件名操作步骤》在SQLServer中重命名数据库是一个常见的操作,但需要确保用户具有足够的权限来执行此操作,:本文主要介绍SQLServer修改数据... 目录一、背景介绍二、操作步骤2.1 设置为单用户模式(断开连接)2.2 修改数据库名称2.3 查找逻辑文件名

Python常用命令提示符使用方法详解

《Python常用命令提示符使用方法详解》在学习python的过程中,我们需要用到命令提示符(CMD)进行环境的配置,:本文主要介绍Python常用命令提示符使用方法的相关资料,文中通过代码介绍的... 目录一、python环境基础命令【Windows】1、检查Python是否安装2、 查看Python的安

全面解析HTML5中Checkbox标签

《全面解析HTML5中Checkbox标签》Checkbox是HTML5中非常重要的表单元素之一,通过合理使用其属性和样式自定义方法,可以为用户提供丰富多样的交互体验,这篇文章给大家介绍HTML5中C... 在html5中,Checkbox(复选框)是一种常用的表单元素,允许用户在一组选项中选择多个项目。本

HTML5 搜索框Search Box详解

《HTML5搜索框SearchBox详解》HTML5的搜索框是一个强大的工具,能够有效提升用户体验,通过结合自动补全功能和适当的样式,可以创建出既美观又实用的搜索界面,这篇文章给大家介绍HTML5... html5 搜索框(Search Box)详解搜索框是一个用于输入查询内容的控件,通常用于网站或应用程

Python并行处理实战之如何使用ProcessPoolExecutor加速计算

《Python并行处理实战之如何使用ProcessPoolExecutor加速计算》Python提供了多种并行处理的方式,其中concurrent.futures模块的ProcessPoolExecu... 目录简介完整代码示例代码解释1. 导入必要的模块2. 定义处理函数3. 主函数4. 生成数字列表5.

Python中help()和dir()函数的使用

《Python中help()和dir()函数的使用》我们经常需要查看某个对象(如模块、类、函数等)的属性和方法,Python提供了两个内置函数help()和dir(),它们可以帮助我们快速了解代... 目录1. 引言2. help() 函数2.1 作用2.2 使用方法2.3 示例(1) 查看内置函数的帮助(

Linux脚本(shell)的使用方式

《Linux脚本(shell)的使用方式》:本文主要介绍Linux脚本(shell)的使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录概述语法详解数学运算表达式Shell变量变量分类环境变量Shell内部变量自定义变量:定义、赋值自定义变量:引用、修改、删

Java使用HttpClient实现图片下载与本地保存功能

《Java使用HttpClient实现图片下载与本地保存功能》在当今数字化时代,网络资源的获取与处理已成为软件开发中的常见需求,其中,图片作为网络上最常见的资源之一,其下载与保存功能在许多应用场景中都... 目录引言一、Apache HttpClient简介二、技术栈与环境准备三、实现图片下载与保存功能1.

Python中使用uv创建环境及原理举例详解

《Python中使用uv创建环境及原理举例详解》uv是Astral团队开发的高性能Python工具,整合包管理、虚拟环境、Python版本控制等功能,:本文主要介绍Python中使用uv创建环境及... 目录一、uv工具简介核心特点:二、安装uv1. 通过pip安装2. 通过脚本安装验证安装:配置镜像源(可

LiteFlow轻量级工作流引擎使用示例详解

《LiteFlow轻量级工作流引擎使用示例详解》:本文主要介绍LiteFlow是一个灵活、简洁且轻量的工作流引擎,适合用于中小型项目和微服务架构中的流程编排,本文给大家介绍LiteFlow轻量级工... 目录1. LiteFlow 主要特点2. 工作流定义方式3. LiteFlow 流程示例4. LiteF