本文介绍了Vue+element-ui 实现表格的分页功能示例,分享给大家,具体如下:
实现效果如下图所示:
template部分:
名称" width="228">
数据部分:获取测试的数据(19个)
40352966,"ratio": 0.0013093788254893862
},{
"name": "15新湖债","marketValue": 307493.82219188084,"ratio": 0.0012426648117401043
},{
"name": "16珠管01","marketValue": 303035.16177009855,"ratio": 0.0012246461719698726
},{
"name": "16重机债","marketValue": 299103.36126325984,"ratio": 0.0012087567140880767
},"marketValue": 8163.960979194436,"ratio": 3.2992750751699765E-5
},"marketValue": 1475.2323613477674,"ratio": 5.961808700804324E-6
},"marketValue": 723.1485963397557,"ratio": 2.92243697100979E-6
},"marketValue": 707.2357910413259,"ratio": 2.85812906700224E-6
},"marketValue": 153.74691109594042,"ratio": 6.213324058700521E-7
}]
}
}
methiods部分:
页码切换
this.currentPage1 = currentPage
this.currentChangePage(this.bondsAllList,currentPage)
},//分页方法(重点)
currentChangePage(list,currentPage) {
let from = (currentPage - 1) this.pageSize;
let to = currentPage this.pageSize;
this.tempList = [];
for (; from < to; from++) {
if (list[from]) {
this.tempList.push(list[from]);
}
}
},}