<el-table
:data="tableData.slice((currentPage-1)*pageSize,currentPage*pageSize)"
height="62vh"
border
style="width: 100%"
>
<el-table-column prop="l1" label="时间(s)" width="120px" align="center"></el-table-column>
<el-table-column
v-for="(item,index) in legend"
:key="index"
:prop="'l'+(index+2)"
:label="item"
align="center"
></el-table-column>
</el-table>
<div class="pager-box" ref="pager">
<div class="total">
共
<span style="color: #259dff;">{{total}}</span> 条记录
</div>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-size="pageSize"
layout="sizes, prev, pager, next"
:total="total"
background
></el-pagination>
</div>
关键点:tableData.slice((currentPage-1)pageSize,currentPagepageSize)
data() {
return {
legend: [
'爆管模拟阀开度',
'爆管点外泄流量开度',
'爆管点上游流量(m3/s)',
'爆管点下游流量(m3/s)',
'爆管点上游隔断阀流速(m/s)',
'爆管点下游隔断阀流速(m/s)',
'爆管点测压管水头(m)',
'爆管点压力(m)',
],
currentPage: 1, // 当前页码
total: 0, // 总条数
pageSize: 20, // 每页的数据条数
}
},
methods: {
handleSizeChange(val) {
this.currentPage = 1
this.pageSize = val
},
handleCurrentChange(val) {
this.currentPage = val
},
}
pager-box的样式:
.pager-box {
display: flex;
justify-content: space-between;
height: 44px;
align-items: center;
align-items: flex-end;
padding: 0 16px 0 16px;
.total {
font-size: 14px;
line-height: 34px;
}
/deep/.btn-prev {
margin-left: 50vw;
line-height: 44px;
}
/deep/.el-input {
width: 50px;
}
/deep/.el-pagination__sizes {
display: none;
}
/deep/.el-pagination.is-background .el-pager li:not(.disabled).active {
background-color: rgba(37, 157, 255, 0.2);
color: #259dff;
}
}