vue element-UI前端分页

需求:后台获取数据,在前端分页

说明:在table组件加入

 :data="tableData.slice((currentPage-1)*pagesize,currentPage*pagesize)"

 其中:currentPage:当前页

           pagesize:页码包含条数当然

当然,以上参数也要和分页参数关联上。

table的插件

 <el-table  :data="tableData.slice((currentPage-1)*pagesize,currentPage*pagesize)" border stripe fit empty-text="暂无数据" style="width: 100%"
                  :default-sort="{prop: 'date', order: 'descending'}">
          <el-table-column
            prop="fbno"
            label="编号"
            sortable
            width="140">
          </el-table-column>
          <el-table-column
            prop="area"
            label="面积"
            sortable
            width="160">
          </el-table-column>
          </el-table>

分页的插件:数据较少,我就每页1、2、3、4条做测试了。

 <div class="paging" >
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[1, 2, 3, 4]"
            :page-size="1"
            background
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
          </el-pagination>
        </div>

关联的data:

 data() {
      return {
        pagesize:1,
        total:0,
        currentPage:1,
              }
    },

关联的方法:

 handleSizeChange(val) {
        this.pagesize =val;
      },
      handleCurrentChange(val) {
        this.currentPage = val;
      },

猜你喜欢

转载自blog.csdn.net/xuerwang/article/details/82226376