element ui 表格里的需要自增
表格里的序号自增:给el-table-column标签加上type="index"即可
vue3 antd jsx table实现表格序号翻页后连续自增
data(){
return {
columns: [
{
title: '序号',
dataIndex: 'order',
key: 'order',
width: '10%',
align: 'center',
className: 'table-center',
slots: {
customRender: 'order'
}
}
]
}
},
setup(){
let filterObj = reactive({
total: 0,
pageSize: 10,
pageCur: 1,
current: 1
});
return {
filterObj
}
},
render() {
// { record,index } record代表对应一行的数据 index代表第一页行的下标 每页都是从0开始 所以通过当前页数来进行处理就可以实现翻页连续自增
const slots = {
order: ({ index }) => {
return <span>{(index += 1) + (this.filterObj.current - 1) * 10}</span>;
},
};
return (
<>
//这里 rowKey 就可以用index 如果record里面没有唯一的键 就用这个
<a-table data-source={this.dataSource} v-slots={slots} columns={this.columns} rowKey={(record,index) => index} pagination={this.filterObj} onChange={this.pageChange} />
</>
);
}