zoukankan      html  css  js  c++  java
  • ant design vue中表格自带分页

    ant design vue中表格里面自带分页,目前使用的是远程加载数据的形式。

    需要注意的是一定要设置total

              <a-table
                    :columns="columns"
                    :data-source="tableData"
                    :row-key="record => record.id"
                    :pagination="pagination"
                    :loading="loading"
                    :scroll="scroll"
                    @change="handleTableChange"
                    tableLayout="fixed"
                    class="table-wrapper"
                >
                         </a-table>

      

          data() {
                return {
                    size: 'small',
                    from:{},
                    tableData: [], 
                    columns,
                    status: [],
                    //分页栏
                    pagination: {
                        position:'bottom',
                        pageSize: 10,
                        current: 1,
                        total: 0
                    },            
                    //表格数据是否正在加载
                    loading: false,
                    //表格表头筛选条件
                    filteredInfo: null,
                    //表格表头排序条件
                    sortedInfo: null,
                    //表格选中行
                    selectedRowKeys: [],
                    //表格横向与纵向宽度
                    //设置表格锁定表头和列时必须设置此配置
                    scroll: {
                        x: 2000,
                        y: "calc(100vh - 450px)",
                    },
                }
            },
          methods: {
                //表格刷新
                refreshTableData(e){
                    if (e) {
                        e.preventDefault();
                        this.pagination.current = 1;
                    }
                    let that = this;
                    let pagination = that.pagination|| {}
                    let sorter = that.sortedInfo|| {}
                    let formData = {...that.form}
                    that.fetch({
                        pageSize: pagination.pageSize,
                        pageNumber: pagination.current,
                        ...formData 
                    })
                },
                //表格分页条件、筛选条件、排序条件发生变化后刷新表格数据
                handleTableChange(pagination, filters, sorter) {
                    console.log(pagination, 'pagination');
                    let that = this;
                    that.sortedInfo = sorter;
                    const pager = { ...that.pagination };
                    pager.current = pagination.current;
                    that.pagination = pager;
                    that.refreshTableData()
    
                },
                //表格渲染
                fetch(params = {}) {
                    console.log('params:', params);
                    this.loading = true;
                    publicapi.getfindAllByLimit(params).then(data => {
                        const pagination = { ...this.pagination };
                        this.loading = false;
                        this.pagination.total = data.preProjectData.totalElements;
                        this.tableData.splice(0, this.tableData.length);
                        this.tableData = data.preProjectData.content
                    });
                },
            } 
    

      

  • 相关阅读:
    js delete 操作符
    js中contains()方法的了解
    绝对地址、相对地址、/、./、../之间的区别
    关于应用版本号的更迭
    js事件的绑定与移除
    js实现阶乘
    圆角和渐变
    css3用到知识点小结
    font-size:0的妙用,用于解决inline或者inline-block造成的间隙
    js怎么把数字转化为字母(A,B.....AA,AB,..)
  • 原文地址:https://www.cnblogs.com/theblogs/p/14738545.html
Copyright © 2011-2022 走看看