element-ui分页功能删除最后一条数据返回上一页
// 为了在删除最后一页的最后一条数据时能成功跳转回最后一页的上一页(pageSize=1时不生效)
let totalPage = Math.ceil((this.total - 1) / this.pageSize)
let currentPage =
this.currentPage > totalPage ? totalPage : this.currentPage
this.currentPage = currentPage < 1 ? 1 : currentPage
完整代码
user_delete(callback) {
let postData = {}
let data = []
for (var i = 0; i < this.selectedList.length; i++) {
data.push(this.selectedList[i].value)
}
postData.data = window.JSON.stringify(data)
deleteTerminalUser(postData).then(res => {
if (res.success == true) {
// 为了在删除最后一页的最后一条数据时能成功跳转回最后一页的上一页(pageSize=1时不生效)
let totalPage = Math.ceil((this.total - 1) / this.pageSize)
let currentPage =
this.currentPage > totalPage ? totalPage : this.currentPage
this.currentPage = currentPage < 1 ? 1 : currentPage
this.$notify({
title: '成功',
message: res.msg,
type: 'success'
})
} else {
this.$notify({
title: '失败',
message: res.msg,
type: 'error'
})
}
callback()
})
// this._user_find()
},