删除列表项时,如果当前页只有一项,删除后分页器跳转到前一页
data() {
return {
currentPage: 1, // 当前页
pageSize: 10, // 每页显示的个数
totalCount: 0, // 总条数
}
}
//删除的时候重新计算当前页码
let totalPage = Math.ceil((this.totalCount-1)/this.pageSize)
this.currentPage = this.currentPage>totalPage&&totalPage>0?totalPage:this.currentPage
或者
//(总条数-1)/每页显示条数
// Math.ceil 向上取整
this.currentPage = Math.ceil((this.totalCount-1)/this.pageSize)
网友评论