完整代码如下:
<a-table :columns="columns" :data-source="students" :pagination="false" rowKey="id" @change="handleTableChange">
<div slot="num" slot-scope="text, record, index">{{ (currentPage - 1) * pageSize + (index + 1) }}</div>
<div slot="action" slot-scope="text, item">
<a-button type="link" :disabled="detail.status === 2" @click="handleDel(item)">删除</a-button>
<a-button
v-if="detail.type === 1"
type="link"
@click="pathTo('/classroom/flow/' + detail.id + '/' + item.id)"
>
流水线</a-button
>
</div>
</a-table>
const columns = [
{
title: '序号',
scopedSlots: { customRender: 'num' }
},
{
title: '学号',
dataIndex: 'no',
align: 'center',
filters: [
{ text: '升序', value: 'no asc' },
{ text: '降序', value: 'no desc ' }
],
filterMultiple: false,
filteredValue: filteredInfo.no || null
},
{
title: '姓名',
dataIndex: 'name',
align: 'center',
filters: [
{ text: '升序', value: 'name asc' },
{ text: '降序', value: 'name desc ' }
],
filterMultiple: false,
filteredValue: filteredInfo.name || null
},
{
title: '操作',
align: 'center',
scopedSlots: { customRender: 'action' }
}
]
其中从分页连续自增序号如下:
<div slot="num" slot-scope="text, record, index">{{ (currentPage - 1) * pageSize + (index + 1) }}</div>
每一页都从1开始
{{index+1}}