最近在项目中遇到使用table分页的功能,所以分享出来给大家希望能够对大家有帮助,话不多说直接上代码

 <template>
<div>
<Table :columns="historyColumns" :data="historyData"></Table>
<Page :total="dataCount" :page-size="pageSize" show-total class="paging" @on-change="changepage" @on-page-size-change="pages" show-sizer show-elevator show-total></Page>
</div>
</template>
<style scoped>
.paging {
float: left;
margin-top: 10px;
}
</style>
<script>
import Cookies from 'js-cookie'; export default {
data() {
return {
ajaxHistoryData: [],
// 初始化信息总条数
dataCount: 0,
// 每页显示多少条
pageSize: 10,
xia: 0, //下一页或者上一页的第一项索引值
historyColumns: [{
"type": "selection",
"align": "center",
"width": "30",
"className": "border-r"
}, {
"title": "用户名",
"align": "center",
"key": "username"
}, {
"title": "姓名",
"align": "center",
"key": "name"
}, {
"title": "所属组织机构",
"align": "center",
"key": "deptName"
}, {
"title": "状态",
"align": "center",
"key": "status"
}, {
"title": "联系电话",
"align": "center",
"key": "mobile" }, {
'title': '操作',
'align': 'center',
'key': 'action',
render: (h, params) => {
return h('div', [
h('Icon', {
props: {
type: 'ios-baseball',
size: 16
},
style: {
marginLeft: '20px'
} }) ]) }
}],
historyData: []
}
},
methods: {
// 获取历史记录信息
handleListApproveHistory() {
let sessionId = Cookies.get('status');
let this1 = this;
this.$http({
headers: {
"Authorization": sessionId,
},
method: 'post',
url: this1.GLOBAL.BASE_URL + '/sys/user/list',
params: {
'deptId': '001',
'offset': 0, //第一页第一项的索引
'limit': 10, //每页显示的条数
},
})
.then(function(res) {
debugger
this1.ajaxHistoryData = res.data.data;
this1.dataCount = res.data.total; this1.historyData = this1.ajaxHistoryData;
})
.catch(function(error) {
//
}) },
pages(num) { //修改每页显示条数时调用
debugger
this.pageSize = num;
this.changepage(1);
},
changepage(index) {
//index当前页码
this.xia = (index - 1) * this.pageSize; let sessionId = Cookies.get('status');
let this1 = this;
this.$http({
headers: {
"Authorization": sessionId,
},
method: 'post',
url: this1.GLOBAL.BASE_URL + '/sys/user/list',
params: {
'deptId': '001',
'offset': this1.xia,
'limit': this1.pageSize,
},
})
.then(function(res) {
debugger
this1.historyData = res.data.data;
})
.catch(function(error) {
//
})
}
},
created() {
this.handleListApproveHistory();
}
}
</script>

代码中一些重要的部分都有标记了注释,如果还有不懂得地方大家可以留言

下面是我的公众号,欢迎大家关注,可以一起学习一起进步:

最新文章

  1. [译]Godot系列教程二 - 场景实例化(Instancing)
  2. CF 445B DZY Loves Chemistry(并查集)
  3. Greedy:The Water Bowls(POJ 3185)
  4. Undefined symbols for architecture x86_64: &quot;_OBJC_CLASS_$_GiftAnimationView&quot;
  5. HttpCache ETag与Last-Modified与Expires
  6. Echarts data数据为空时,显示“-”
  7. makefile for VCS from Syn@psys
  8. 如何用C程序简单演奏乐曲
  9. class之cls
  10. Code Lock
  11. Outlook邮箱配置
  12. OC学习15——文件I/O体系
  13. Java Servlet API中文说明文档
  14. vue 在methods中调用mounted中的方法?
  15. [SDOI2010]代码拍卖会
  16. Struts2 转换器
  17. jQuery的deferred对象解析
  18. c# 多线程简化
  19. Java作业:第二次过程性考核 ——长春职业技术学院 16级网络工程
  20. Pytho条件判断

热门文章

  1. hibernate--博客
  2. MongoDB复制集原理、环境配置及基本测试详解
  3. python-&gt;解析xml文件
  4. windows7,python3使用time.strftime()函数报ValueError: embedded null byte
  5. ARGB 颜色取值与透明度对照表
  6. js 整数型数组和字符型数组相互转换
  7. python安装simplejson
  8. linux查看cpu个数,线程数及cpu型号
  9. Vue使用Typescript开发编译时提示“ERROR in ./src/main.ts Module build failed: TypeError: Cannot read property &#39;afterCompile&#39; of undefined”的解决方法
  10. Java的反射机制的详细应用