分页问题

2022-08-09  本文已影响0人  洪锦一

删除列表项时,如果当前页只有一项,删除后分页器跳转到前一页

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)
上一篇 下一篇

猜你喜欢

热点阅读