ant-design-vue中設(shè)置Table每頁(yè)顯示的條目數(shù)量方式
ant-design-vue設(shè)置Table每頁(yè)顯示的條目數(shù)量
新項(xiàng)目中設(shè)置分頁(yè)條數(shù)遇到點(diǎn)問(wèn)題,查閱百度發(fā)現(xiàn)都是使用:
pagination="false"禁用table的分頁(yè)功能,自己重新封裝一個(gè)分頁(yè),其實(shí)duck不必這么做,官方文檔中提供了一個(gè)pageSize,自然有自己的妙用!
?<a-table :columns="columns" :data-source="data" bordered ?:pagination="{ pageSize: 12 }"></a-table> //pageSize為每頁(yè)顯示的條數(shù)
這樣,我們就輕輕松松的實(shí)現(xiàn)了限值頁(yè)面條數(shù)的功能~
ant-design-vue a-table的分頁(yè)
<a-table :columns="columns" //列 :dataSource="tableDatas" //數(shù)據(jù) :loading="loading" :pagination="pagination" //分頁(yè)屬性 @change="handleTableChange"http://點(diǎn)擊分頁(yè)中數(shù)字時(shí)觸發(fā)的方法 :rowKey="tableDatas => tableDatas.id" //每一行的標(biāo)識(shí) > <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,//每頁(yè)中顯示10條數(shù)據(jù) showSizeChanger: true, pageSizeOptions: ["10", "20", "50", "100"],//每頁(yè)中顯示的數(shù)據(jù) showTotal: total => `共有 ${total} 條數(shù)據(jù)`, //分頁(yè)中顯示總的數(shù)據(jù) }, loading: true, // 查詢(xún)參數(shù) queryParam: { page: 1,//第幾頁(yè) size: 10,//每頁(yè)中顯示數(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)用查詢(xún)接口為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; }); },
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
element-ui中el-form-item內(nèi)的el-select該如何自適應(yīng)寬度
自從用了element-ui,確實(shí)好用,該有的組件都有,但是組件間的樣式都固定好了,下面這篇文章主要給大家介紹了關(guān)于element-ui中el-form-item內(nèi)的el-select該如何自適應(yīng)寬度的相關(guān)資料,需要的朋友可以參考下2022-11-11基于vue v-for 循環(huán)復(fù)選框-默認(rèn)勾選第一個(gè)的實(shí)現(xiàn)方法
下面小編就為大家分享一篇基于vue v-for 循環(huán)復(fù)選框-默認(rèn)勾選第一個(gè)的實(shí)現(xiàn)方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-03-03Vue?cli3.0創(chuàng)建Vue項(xiàng)目的簡(jiǎn)單過(guò)程記錄
Vue CLI是一個(gè)基于Vue.js進(jìn)行快速開(kāi)發(fā)的完整系統(tǒng),下面這篇文章主要給大家介紹了關(guān)于Vue?cli3.0創(chuàng)建Vue項(xiàng)目的相關(guān)資料,文中通過(guò)圖文介紹的非常詳細(xì),需要的朋友可以參考下2022-08-08Vue項(xiàng)目打包部署到apache服務(wù)器的方法步驟
這篇文章主要介紹了Vue項(xiàng)目打包部署到apache服務(wù)器,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-02-02Vue+Echart實(shí)現(xiàn)利用率表盤(pán)效果的示例代碼
這篇文章主要為大家詳細(xì)介紹了Vue如何利用Echart實(shí)現(xiàn)利用率表盤(pán)的效果,文中的示例代碼講解詳細(xì),具有一定的借鑒價(jià)值,需要的可以參考一下2023-04-04vue.extend實(shí)現(xiàn)alert模態(tài)框彈窗組件
這篇文章主要為大家詳細(xì)介紹了vue.extend實(shí)現(xiàn)alert模態(tài)框彈窗組件,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-04-04基于mpvue的簡(jiǎn)單彈窗組件mptoast使用詳解
這篇文章主要介紹了基于mpvue的簡(jiǎn)單彈窗組件mptoast使用詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-08-08深入理解Vue父子組件生命周期執(zhí)行順序及鉤子函數(shù)
本文通過(guò)實(shí)例代碼給大家介紹了Vue父子組件生命周期執(zhí)行順序及鉤子函數(shù)的相關(guān)知識(shí),非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2018-08-08