美文网首页工作生活
elemnt-vue-admin实现分页

elemnt-vue-admin实现分页

作者: xyz098 | 来源:发表于2019-07-01 19:30 被阅读0次

两种方法

  1. 每次点击不同的页调一次后端,查询数据限制
  2. 加载所有数据,分页展示

第二种的实现

  1. javascript

    // 导入组件
    import Pagination from '@/components/Pagination' 
    
    export default {
      // 引用组件
      components: { Pagination },
      data() {
          // list存放每页要显示的数据
          list: [],
          total: 0,
          listQuery: {
            page: 1,
            limit: 10
          }
      }
    }
    
    // 计算当前页要展示的数据
    computed: {
        getList() {
          const lists = this.GroupsList.slice((this.listQuery.page - 1) * this.listQuery.limit, (this.listQuery.page - 1) * this.listQuery.limit + this.listQuery.limit)
          return lists
        }
    },
    
    created() {
        this.getGroups()
    },
    
    methods: {
        async getGroups() {
          const res = await getGroups()
          this.GroupsList = res.data
          this.total = this.GroupsList.length
          // 第一页数据初始化   
          this.list = this.getList
       },
       // 点击不同页时调用的方法
       handlePageList() {
          this.list = this.getList
       },
    
  2. template

    <!-- 展示当前页数据list -->
    <el-table :data="list" style="width: 100%;margin-top:30px;" border>
       <el-table-column align="center" label="用户组" width="220">
            <template slot-scope="scope">
              {{ scope.row.usergroup }}
            </template>
       </el-table-column>    
    </el-table>
    
    <!-- 点击不同页调用handlePageList方法 -->
    <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="handlePageList" />
    

相关文章

  • elemnt-vue-admin实现分页

    两种方法 每次点击不同的页调一次后端,查询数据限制 加载所有数据,分页展示 第二种的实现 javascript//...

  • 分页的几种实现方式

    一:分页的几种实现方式 1.1:手动实现一个分页 1.2通过 sql语句 实现分页 1.3...

  • Vue实现分页操作

    1,分页时候引入vue自带的分页组件实现: (1)

  • Django3.0实践五(restFramework自定义分页)

    一.基于PageNumberPagination实现分页 Rest Framework分页参考地下:https:/...

  • flask实现分页

    原文地址数据库实现分页offset:使用offset可以实现数据库分页功能questions = Question...

  • UIColletionView

    自定义flowlayout实现分页 collectionView 分页 & 偏移位置 collectionView...

  • D4 springboot分页查询

    使用PageHelper分页插件实现分页 https://pagehelper.github.io/[http...

  • Mybatis分页

    分页 使用limit实现分页 语法: select * from xxx limit startIndex,pag...

  • Java Web 之分页技术

    本文包括:1、分页技术概述2、实现分页3、完善分业——分页工具条4、几种常见的分页工具条 1、分页技术概述 物理分...

  • MyBatis分页和动态标签

    MyBatis分页 内存分页 MyBatis提供了RowBounds类实现内存分页功能。其原理是首先根据sql语句...

网友评论

    本文标题:elemnt-vue-admin实现分页

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