当前位置: 首页 > news >正文

antd a-list 添加分页

会分为三部分

template

      <a-list item-layout="horizontal" :data-source="localData" :pagination="{...paginationProps,current:currentPage}"><a-list-item slot="renderItem" slot-scope="item"><a-list-item-meta><input slot="title" type="checkbox" style="width:15px;height:15px" value="item" @click="select(item)"><a slot="title" href="javascript:void(0);" @click="getsrc(item)">{{ item.name.length > 20 ? item.name.substr(0, 20) + '...' : item.name }}</a></a-list-item-meta><a slot="actions" @click="getsrc(item)">查看</a><a slot="actions" :href="originUrl + item.name" :download="item.name">下载</a><a slot="actions" @click="del(item)">删除</a></a-list-item></a-list>

分页最主要的代码: pagination

      <a-list item-layout="horizontal" :data-source="localData" :pagination="{...paginationProps,current:currentPage}"></a-list>

data

      // 分页展示的数据localData: [],// 整体的数据localDataSource: [],// 加载第一页的页数 页码数currentPage: 1,// 每页条数pageSize: 14,

js 

computed  在页面首次渲染时

    // 床位管理的分页paginationProps () {const _this = thisreturn {pageSize: 14,total: this.localDataSource.length,hideOnSinglePage: true,onChange (page, pageSize) {_this.currentPage = pagegetfilelist({page: _this.currentPage,size: _this.pageSize,department: _this.department}).then(res => {const listoption = []const titleIdAll = []res.list.map((item, index) => {const itemoptin = {}itemoptin.id = item.iditemoptin.name = item.content.substr(item.content.lastIndexOf('/') + 1, item.content.length - item.content.lastIndexOf('/'))listoption.push(itemoptin)titleIdAll.push(item.id)_this.titleIdAllToday = titleIdAll})_this.localData = listoption// 初始化input所有的框var input = document.getElementsByTagName('input')for (var i = 0; i < input.length; i++) {input[i].checked = false}}).catch(() => {this.$message.error('获取列表失败')_this.display = false})}}}

也在computed里

...mapGetters(['department']),

穿插一个小知识 字符串截取 与本文分页无关

       itemoptin.name = item.content.substr(item.content.lastIndexOf('/') + 1, item.content.length - item.content.lastIndexOf('/'))

 

 js methods

    // 获取列表getfilelist () {getfilelist({department: this.department}).then(res => {this.localDataSource = res.listif (this.localDataSource.length > 0) this.display = true}).catch(() => {this.$message.error('获取列表失败')this.display = false})getfilelist({page: this.currentPage,size: this.pageSize,department: this.department}).then(res => {const listoption = []const titleIdAll = []res.list.map((item, index) => {const itemoptin = {}itemoptin.id = item.iditemoptin.name = item.content.substr(item.content.lastIndexOf('/') + 1, item.content.length - item.content.lastIndexOf('/'))listoption.push(itemoptin)titleIdAll.push(item.id)this.titleIdAllToday = titleIdAll})this.localData = listoptionif (this.localData.length > 0) this.display = true// }}).catch(() => {this.$message.error('获取列表失败')this.display = false})},

http://www.lryc.cn/news/171768.html

相关文章:

  • MySQL注入绕安全狗脚本 -- MySQLByPassForSafeDog,以及端口爆破工具 -- PortBrute配置使用
  • R语言绘制热图
  • jmeter线程组 bzm - Concurrency Thread Group 阶梯式压测
  • 计算即时订单比例-首单使用开窗函数row_number()
  • flink集群与资源@k8s源码分析-集群
  • 商城开发:商城系统的哪些功能值得企业去关注?
  • calibre和cpolar搭建一个私有的网络书库
  • c++ nlohmann::json 中文支持
  • vue3 | defineExpose的使用
  • PaddleSeg学习3——使用PP-LiteSeg模型对道路进行分割
  • 时序数据库的关键技术点总结
  • 【ROS】机器人使用Nomachine进行远程控制
  • Jmeter系列-定时器Timers的基本介绍(11)
  • 【华为OD机试python】求满足条件的最长子串的长度【2023 B卷|100分】
  • iOS技术博主指南:填写苹果应用上架中的隐私政策信息
  • Spring事件机制之ApplicationEvent
  • 【操作系统笔记】内存寻址
  • webpack自定义loader解析指定后缀名文件
  • 基于Kintex UltraScale系列FPGA KU060/KU115高性能PCIe数据预处理载板(5GByte/s带宽)
  • Cesium 地球(2)-瓦片创建
  • Selenium-介绍下其他骚操作
  • 【C++从0到王者】第三十一站:map与set
  • 生产消费者模型的介绍以及其的模拟实现
  • Unity ML-Agents默认接口参数含义
  • 【python数据分析基础】—pandas中loc()与iloc()的介绍与区别
  • ad18学习笔记十一:显示和隐藏网络、铺铜
  • 全国职业技能大赛云计算--高职组赛题卷④(私有云)
  • Camera Tunning ISP 模块面试总结
  • AOSP源码中Android.mk文件中的反斜杠符号(\)的作用和使用
  • 如何查看mysql的存储引擎