• antd a-list 添加分页


    会分为三部分

    template

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

    分页最主要的代码: pagination

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

    data

    1. // 分页展示的数据
    2. localData: [],
    3. // 整体的数据
    4. localDataSource: [],
    5. // 加载第一页的页数 页码数
    6. currentPage: 1,
    7. // 每页条数
    8. pageSize: 14,

    js 

    computed  在页面首次渲染时

    1. // 床位管理的分页
    2. paginationProps () {
    3. const _this = this
    4. return {
    5. pageSize: 14,
    6. total: this.localDataSource.length,
    7. hideOnSinglePage: true,
    8. onChange (page, pageSize) {
    9. _this.currentPage = page
    10. getfilelist({
    11. page: _this.currentPage,
    12. size: _this.pageSize,
    13. department: _this.department
    14. }).then(res => {
    15. const listoption = []
    16. const titleIdAll = []
    17. res.list.map((item, index) => {
    18. const itemoptin = {}
    19. itemoptin.id = item.id
    20. itemoptin.name = item.content.substr(item.content.lastIndexOf('/') + 1, item.content.length - item.content.lastIndexOf('/'))
    21. listoption.push(itemoptin)
    22. titleIdAll.push(item.id)
    23. _this.titleIdAllToday = titleIdAll
    24. })
    25. _this.localData = listoption
    26. // 初始化input所有的框
    27. var input = document.getElementsByTagName('input')
    28. for (var i = 0; i < input.length; i++) {
    29. input[i].checked = false
    30. }
    31. }).catch(() => {
    32. this.$message.error('获取列表失败')
    33. _this.display = false
    34. })
    35. }
    36. }
    37. }

    也在computed里

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

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

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

     

     js methods

    1. // 获取列表
    2. getfilelist () {
    3. getfilelist({
    4. department: this.department
    5. }).then(res => {
    6. this.localDataSource = res.list
    7. if (this.localDataSource.length > 0) this.display = true
    8. }).catch(() => {
    9. this.$message.error('获取列表失败')
    10. this.display = false
    11. })
    12. getfilelist({
    13. page: this.currentPage,
    14. size: this.pageSize,
    15. department: this.department
    16. }).then(res => {
    17. const listoption = []
    18. const titleIdAll = []
    19. res.list.map((item, index) => {
    20. const itemoptin = {}
    21. itemoptin.id = item.id
    22. itemoptin.name = item.content.substr(item.content.lastIndexOf('/') + 1, item.content.length - item.content.lastIndexOf('/'))
    23. listoption.push(itemoptin)
    24. titleIdAll.push(item.id)
    25. this.titleIdAllToday = titleIdAll
    26. })
    27. this.localData = listoption
    28. if (this.localData.length > 0) this.display = true
    29. // }
    30. }).catch(() => {
    31. this.$message.error('获取列表失败')
    32. this.display = false
    33. })
    34. },

  • 相关阅读:
    基于微服务+Java+Spring Cloud +UniApp +MySql开发的智慧工地源码(物联网、人工智能、AI识别、危大工程)
    Jsp+Servlet+Mysql实现的高校学生社团管理系统
    mongodb 数据块的迁移流程介绍
    nginx配置指南
    FFMPEG centos 安装指南
    SWAT-MODFLOW地表水与地下水耦合教程
    信用卡评测系列——阳光惠生活APP深化服务客户品牌理念,焕新升级7.0版
    探究竟篇之React中的state
    【Linux】安装Nginx
    远程访问云服务器CentOS下 jupyter服务 【保姆级教程】
  • 原文地址:https://blog.csdn.net/weixin_63199745/article/details/132846562