不分页的情况下,可以type="index";
data() {
return {
tableColumn: [{type: 'index', width: 70, align: 'center', title: '序号'}]
}
}
分页的情况下,有两种方式:
方式一:在data中定义列表项时赋值
data() {
return {
tableColumn: [{
width: 70,
align: 'center',
title: '序号',
render: (h,params) => {
return h('span', params.index + (this.searchCondition.pageNum -1) * this.searchCondition.pageSize + 1)
}
}]
}
}
方式二:在接口返回的数据中增加索引值
data() {
return {
tableColumn: [{key: 'index',width: 70,align: 'center',title: '序号'}]
}
},
methods: {
async getWorldWideList() {
let res = await API.getWorldWideListApi(this.searchCondition)
if (res.data.success) {
res.data.data.list = res.