美文网首页
分页问题

分页问题

作者: 洪锦一 | 来源:发表于2022-08-09 16:04 被阅读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)
    

    相关文章

      网友评论

          本文标题:分页问题

          本文链接:https://www.haomeiwen.com/subject/kwunwrtx.html