antd design vue分页组件
生活随笔
收集整理的這篇文章主要介紹了
antd design vue分页组件
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
我們?cè)谑褂梅猪摻M件的時(shí)候可以有兩種方法:
第一種是直接用表格()的自定義:pagination屬性最方便;如下圖所示:
第二種是分頁組件
這里我總結(jié)的是第二種方法的使用,由于是 Ant Design Vue 的組件,所以必須安裝Ant Design Vue才能使用,具體的安裝請(qǐng)看官網(wǎng)~
1.添加分頁組件
<div class="seaTable"><a-table :columns="columns" :data-source="roleListArray" bordered :pagination="false"><template v-for="col in ['序號(hào)', '聯(lián)系人']" :slot="col" slot-scope="text, record, index"><div :key="col"><a-input v-if="record.editable" style="margin: -5px 0" :value="text"@change="e => handleChange(e.target.value, record.key, col)" /><template v-else>{{ text }}</template></div></template><template slot="operation" slot-scope="text, record"><a @click="editShow">修改</a></template></a-table><!-- 分頁 --><div class="pagein"><a-pagination v-model="pages" :total="total" :page-size="rows" show-less-items:show-total="total => `共${total}條數(shù)據(jù)`" @change="onChangePage" /></div></div>2.定義所用到的變量和存放數(shù)據(jù)的數(shù)組roleListArray
?3.聯(lián)調(diào)接口
- vuex配置接口信息
- 組件頁面調(diào)用接口獲取數(shù)據(jù)
4.初始化數(shù)據(jù)加載
?5.將獲取到的數(shù)據(jù)遍歷頁面,更改其數(shù)據(jù)源
?6.更改列名的dataIndex值,保證其與接口中的字段一一對(duì)應(yīng)
?7.效果
在這里需要注意的一點(diǎn)是:
調(diào)用接口的時(shí)候一定要去更新total值,在發(fā)送請(qǐng)求前要更改pages當(dāng)前頁和rows的值,否則一直是默認(rèn)值1和5,因?yàn)槲乙婚_始給定的值就是1和5,值可以更改
總結(jié)
以上是生活随笔為你收集整理的antd design vue分页组件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Excel插件E灵,一键合并相同且相邻的
- 下一篇: 3DMAX设置鼠标命令快捷键