el-table简单封装 含分页
el-table组件封装代码
<template>
<div>
<el-table :data="form.promotionGoodsList" style="width: 100%">
<!-- 其他需要展示的列 -->
</el-table>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[5, 10, 20, 50]"
:page-size="pageSize"
:total="total"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
</div>
</template>
<script>
export default {
data() {
return {
currentPage: 1,
pageSize: 10,
total: 20,
form:{
promotionGoodsList:[]
},
dataList:[]
};
},
computed: {
'form.promotionGoodsList'() {
const start = (this.currentPage - 1) * this.pageSize;
const end = start + this.pageSize;
return this.dataList.slice(start, end);
},
},
methods: {
handleSizeChange(val) {
this.pageSize = val;
this.currentPage = 1;
},
handleCurrentChange(val) {
this.currentPage = val;
},
},
};
</script>