ant-design-vue中設(shè)置Table每頁顯示的條目數(shù)量方式
ant-design-vue設(shè)置Table每頁顯示的條目數(shù)量
新項目中設(shè)置分頁條數(shù)遇到點問題,查閱百度發(fā)現(xiàn)都是使用:
pagination="false"禁用table的分頁功能,自己重新封裝一個分頁,其實duck不必這么做,官方文檔中提供了一個pageSize,自然有自己的妙用!
?<a-table :columns="columns" :data-source="data" bordered ?:pagination="{ pageSize: 12 }"></a-table>
//pageSize為每頁顯示的條數(shù)這樣,我們就輕輕松松的實現(xiàn)了限值頁面條數(shù)的功能~
ant-design-vue a-table的分頁
<a-table
:columns="columns" //列
:dataSource="tableDatas" //數(shù)據(jù)
:loading="loading"
:pagination="pagination" //分頁屬性
@change="handleTableChange"http://點擊分頁中數(shù)字時觸發(fā)的方法
: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:;" rel="external nofollow" rel="external nofollow" @click="handleAdd(record)" >
<i class="iconfont icon-table-edit" />編輯
</a>
<a href="javascript:;" rel="external nofollow" rel="external nofollow" @click="deleHostData(record)">
<i class="iconfont icon-tableEmpty" />刪除
</a>
</template>
<span>
<i class="iconfont icon-tableMore" />
</span>
</a-popover>
</div>
</span>
</a-table>//data中的數(shù)據(jù)data() {
return {
pagination: {
total: 0,
pageSize: 10,//每頁中顯示10條數(shù)據(jù)
showSizeChanger: true,
pageSizeOptions: ["10", "20", "50", "100"],//每頁中顯示的數(shù)據(jù)
showTotal: total => `共有 ${total} 條數(shù)據(jù)`, //分頁中顯示總的數(shù)據(jù)
},
loading: true,
// 查詢參數(shù)
queryParam: {
page: 1,//第幾頁
size: 10,//每頁中顯示數(shù)據(jù)的條數(shù)
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();
},//調(diào)用查詢接口為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;
});
},以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
vue點擊彈窗自動觸發(fā)點擊事件的解決辦法(模擬場景)
本文通過案例場景給大家介紹vue點擊彈窗自動觸發(fā)點擊事件的解決辦法,通過兩種方法給大家分享vue 自動觸發(fā)點擊事件的處理方法,對vue自動觸發(fā)點擊事件相關(guān)知識感興趣的朋友一起看看吧2021-05-05
sortable+element 實現(xiàn)表格行拖拽的方法示例
這篇文章主要介紹了sortable+element 實現(xiàn)表格行拖拽的方法示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2019-06-06
Vue+Element ui 根據(jù)后臺返回數(shù)據(jù)設(shè)置動態(tài)表頭操作
這篇文章主要介紹了Vue+Element ui 根據(jù)后臺返回數(shù)據(jù)設(shè)置動態(tài)表頭操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-09-09
Element基于el-input數(shù)字范圍輸入框的實現(xiàn)
本文主要介紹了?Element基于el-input數(shù)字范圍輸入框的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-04-04

