注意三处,即可实现:
1.<s-table> 标签中的属性:
:pagination="pagination"
此属性表示使用自定义分页;
在return中添加自定义分页:
pagination: {
total: 0,
pageSize: 10, // 每页中显示10条数据
showSizeChanger: true,
pageSizeOptions: ['10', '20', '60', '100'], // 每页中显示的数据
showTotal: total => `共有 ${total} 条数据` // 分页中显示总的数据
},
2.列表字段中添加序号字段,具体如下:
{
title: '序号',
dataIndex: 'xh',
width: 100,
fixed: 'left'
},
3.给列表数据中拼装序号字段值(重点):
loadData: parameter => {
return getTableList(Object.assign(parameter, this.queryParam))
.then(res => {
// res.data.list.reverse()
// 给每行数据增加一个当前页码的属性,序号自增时判断
res.rows.forEach((value, index) => {
value.xh = ((res.pageNum - 1) * this.pagination.pageSize) + (index + 1)
})
return res
})
},