博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Ant Design Vue 如何分页(后台传入)
阅读量:4029 次
发布时间:2019-05-24

本文共 1480 字,大约阅读时间需要 4 分钟。

我们在使用分页使,直接用表格()的自定义:pagination属性最方便;如下图所示:

基于VUE,我们必须在data中定义paginationOpt对象,代码片段如下:

// 分页      paginationOpt: {
defaultCurrent: 1, // 默认当前页数 defaultPageSize: 5, // 默认当前页显示数据的大小 total: 0, // 总数,必须先有 showSizeChanger: true, showQuickJumper: true, pageSizeOptions: ["5", "10", "15", "20"], showTotal: (total) => `共 ${
total} 条`, // 显示总数 onShowSizeChange: (current, pageSize) => {
this.paginationOpt.defaultCurrent = 1; this.paginationOpt.defaultPageSize = pageSize; this.searchCameraFrom(); //显示列表的接口名称 }, // 改变每页数量时更新显示 onChange: (current, size) => {
this.paginationOpt.defaultCurrent = current; this.paginationOpt.defaultPageSize = size; this.searchCameraFrom(); }, },

调用接口时,❤一定要更新total值!!!!!❤并在发送请求前结构当前页和pagesize的值,否则一直时默认值1和5(我这边初始时1和5,可自己更改)

// 查询    searchCameraFrom() {
console.log(this.cameraParams); const {
defaultCurrent, defaultPageSize } = this.paginationOpt; this.$api.Camera.getCameraList({
currPage: defaultCurrent, pageSize: defaultPageSize, info: this.cameraParams, }) .then((res) => {
if (res.code != "200") {
return Promise.reject; } console.log(res); this.cameraList = res.data; this.paginationOpt.total = res.total; }) .catch(() => {
}); },

转载地址:http://dmlbi.baihongyu.com/

你可能感兴趣的文章
gstreamer插件之 videotestsrc
查看>>
autoupdate script
查看>>
linux 驱动开发 头文件
查看>>
/etc/resolv.conf
查看>>
container_of()传入结构体中的成员,返回该结构体的首地址
查看>>
linux sfdisk partition
查看>>
ipconfig,ifconfig,iwconfig
查看>>
opensuse12.2 PL2303 minicom
查看>>
电平触发方式和边沿触发的区别
查看>>
网络视频服务器移植
查看>>
Encoding Schemes
查看>>
移植QT
查看>>
如此调用
查看>>
计算机的发展史
查看>>
带WiringPi库的交叉编译如何处理一
查看>>
带WiringPi库的交叉笔译如何处理二之软链接概念
查看>>
Spring事务的七种传播行为
查看>>
ES写入找不到主节点问题排查
查看>>
Java8 HashMap集合解析
查看>>
ArrayList集合解析
查看>>