題:在使用element-ui?的table表格時,會發(fā)現(xiàn)它每一頁的序號都會從1開始,那怎么才能讓它延續(xù)上一頁的序號呢?
index屬性寫明了如果設(shè)置了?type=index
,可以通過傳遞?index
?屬性來自定義索引文章來源地址http://www.zghlxwxcb.cn/news/detail-636954.html
利用計算屬性解決問題:
<el-table-column type="index" :index="hIndex" label="序號" width="120" />
export default {
data() {
return {
page: 1, //當前頁數(shù)
pagesize: 2, //每頁兩條數(shù)據(jù)
}
},
// 計算屬性
computed: {
hIndex() {
// 當前頁數(shù) - 1 * 每頁數(shù)據(jù)條數(shù) + 1
return (this.page - 1) * this.pagesize + 1
}
}
}
利用函數(shù)方法解決問題
methods: {
hIndex(index) {
// 當前頁數(shù) - 1 * 每頁數(shù)據(jù)條數(shù) + index + 1 ( index 是索引值,從0開始)
return (this.page - 1) * this.pagesize + index + 1
}
}
文章來源:http://www.zghlxwxcb.cn/news/detail-636954.html
到了這里,關(guān)于在Element-ui的table表格中,如何讓分頁的序號延續(xù)上一頁的序號的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!