elementui删除最后一页数据时跳转回上一页

 data(){
    
    
      return {
    
    
        currentPage: 1, // 当前页数
        total:0, // 总页数
        pageSize:5, // 每页显示多少条
        },

删除时:
在这里插入图片描述

            const totalPage = Math.ceil((_this.total  -1 ) / _this.pageSize) // 总页数
            _this.currentPage = _this.currentPage > totalPage ? totalPage : _this.currentPage
            _this.currentPage = _this.currentPage < 1 ? 1 : _this.currentPage

批量删除时:
在这里插入图片描述

           // 批量删除最后一页数据跳转回上一页
            const totalPage = Math.ceil((this.total - this.multipleSelection.length) / this.pageSize) // 剩余数据总页数
            this.currentPage = this.currentPage > totalPage ? totalPage : this.currentPage
            this.currentPage = this.currentPage < 1 ? 1 : this.currentPage
           

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/jq1223/article/details/114438826