問題回溯:使用el-pagination組件 選擇切換當前分頁 頁數(shù)為2
問題結(jié)果:el-pagination組件 當前頁切換失敗 一直都是 1,接口傳參分頁數(shù)據(jù)是2,打印當前分頁也是2
解決方案1:使用 current-page參數(shù) .sync 修飾符
解決方案2:檢查獲取表格方法的時候 取消手動設(shè)置 total = 0文章來源:http://www.zghlxwxcb.cn/news/detail-859941.html
例子:文章來源地址http://www.zghlxwxcb.cn/news/detail-859941.html
<el-table
:data="tableData"
style="width: 100%">
<el-table-column prop="date" label="日期" width="180"></el-table-column>
</el-table>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="page.current"
:page-sizes="[100, 200, 300, 400]"
:page-size="page.size"
layout="total, sizes, prev, pager, next, jumper"
:total="page.total">
</el-pagination>
tableData:[]
page:{
current:1,
size:10,
total:0
}
//獲取表格參數(shù)
getTable(){
this.tableData = []
this.page.total = 0 //這一步會重新賦值 total,導致current-page頁數(shù)異常 一直都會是 1,使用.sync也無效
//接口調(diào)用
//接口調(diào)用成功 賦值
this.tableData = res.data || []
this.page.total = res.total || 0
}
到了這里,關(guān)于element 分頁切換時:current-page無效 頁數(shù)不會跟著一起切換的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!