<el-pagination
background
layout="total, prev, pager, next"
:current-page="searchForm.page"
:page-sizes="[10, 20, 30, 40, 50]"
:page-size="searchForm.size"
:total="total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
data() {
return {
searchForm: {
page: 1,
size: 10
},
// 换页
handleCurrentChange: function(val) {
this.searchForm.page = val
this.getTableData()
},
// 每页显示数量
handleSizeChange: function(val) {
this.searchForm.size = val
setTimeout(() => { this.getTableData() }, 0)
},
// 获取页面表格
getTableData: function() {
const params = Object.assign({}, this.searchForm)
params.page = params.page - 1 // **给后台的page参数,进行减1**
API.dictListAPI(params).then(response => {
const res = response
if (res.code === '200') {
this.tableData = res.data.content
this.total = res.data.total
} else {
this.$errorMsg(res.errmsg)
}
}).catch(error => {
this.$errorMsg('' + error)
})
}