liuqianrong

前端分页

template:

<div class="pagination">
            <el-pagination
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[15]"
            :page-size="15"
            layout="total, sizes, prev, pager, next, jumper"
            :total="totalCount">
            </el-pagination>
</div>

data:

totalCount:0,

currentPage:1,

totalCount存放总数,currentPage为当前页

methods:

      search:function(){
            var self = this;
            self.$axios.post(self.$global.host+\'/api\',{
                a:self.a,
            }).then((response) => {
                if(response.data.code=="000000"){
                    self.oldData = response.data.result;
                    self.totalCount = response.data.result.length;
                    self.showTable();
                }else{
                    self.$message({
                        message: response.data.message,
                        type: \'warning\'
                    });
                    return false;
                }
            }, (response) => {
                    self.$message({
                        message: response.data.message,
                        type: \'warning\'
                    });  
                    return false;
            })
      },

oldData存放所有数据

     showTable:function(){
        this.tableData = this.oldData.slice((this.currentPage-1)*15,this.currentPage*15);
      },
      handleCurrentChange(currentPage){
        this.currentPage = currentPage;
        this.showTable();
      },

因为我想15条/页,所以用15为基数分割

 

分类:

技术点:

相关文章:

  • 2021-08-07
  • 2021-09-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-15
猜你喜欢
  • 2021-12-04
  • 2022-12-23
  • 2021-08-07
  • 2021-08-23
  • 2022-12-23
  • 2021-10-21
相关资源
相似解决方案