ant-design-vue a-table的分頁


 <a-table
        :columns="columns"       //列
        :dataSource="tableDatas"  //數據
        :loading="loading"
        :pagination="pagination"  //分頁屬性
        @change="handleTableChange"//點擊分頁中數字時觸發的方法
        :rowKey="tableDatas => tableDatas.id"    //每一行的標識
      >
        <span slot="action" slot-scope="text, record">  //放表格中操作的按鈕
          <div class="tabBtn" >
            <a-popover placement="bottomRight" overlayClassName="tableBtn">
              <template slot="title">
                <a href="javascript:;" @click="handleAdd(record)" >
                  <i class="iconfont icon-table-edit" />編輯
                </a>
                <a href="javascript:;" @click="deleHostData(record)">
                  <i class="iconfont icon-tableEmpty" />刪除
                </a>
              </template>
              <span>
                <i class="iconfont icon-tableMore" />
              </span>
            </a-popover>
          </div>
        </span>
      </a-table>
復制代碼
復制代碼
//data中的數據
data() { return { pagination: { total: 0, pageSize: 10,//每頁中顯示10條數據 showSizeChanger: true, pageSizeOptions: ["10", "20", "50", "100"],//每頁中顯示的數據 showTotal: total => `共有 ${total} 條數據`, //分頁中顯示總的數據 },
loading: true, // 查詢參數 queryParam: { page: 1,//第幾頁 size: 10,//每頁中顯示數據的條數 hosName: "", hosCode: "", province: "", city: "" }, };
復制代碼
復制代碼
    handleTableChange(pagination) {
      this.pagination.current = pagination.current;
      this.pagination.pageSize = pagination.pageSize;
      this.queryParam.page = pagination.current;
      this.queryParam.size = pagination.pageSize;
      this.getTableList();
    },
//調用查詢接口為dataSource 賦值
    getTableList() {
      this.loading = true;
      retriveHosData(this.queryParam).then(res => {
        if (res.message === "SUCCESS") {
          const pagination = { ...this.pagination };
          pagination.total = res.data.total;
          this.tableDatas = res.data.list;
          this.pagination = pagination;
        }
        this.loading = false;
      });
    },
 

原文鏈接: cnblogs.com/lvlvlv/p/11543575.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM