Vue implements table paging function

Vue implements table paging function

This article example shares the specific code of Vue to realize the table paging function for your reference. The specific content is as follows

Directly on the code:

Here is the template part, which mainly consists of a table that needs to be paginated and a paginator. The key point is that the data attribute of the table uses a slice interception method.

<el-table
        v-loading="listLoading"
        :data="
          list.slice((currentPage - 1) * pageSize, currentPage * pageSize)
        "
        element-loading-text="Loading"
        highlight-current-row
        border
      >
        <el-table-column align="center" label="Serial number" width="90">
          <template slot-scope="scope">
            {{ scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column label="Avatar" align="center" width="150">
          <template slot-scope="scope">
            <el-avatar :src="scope.row.avatar"></el-avatar>
          </template>
        </el-table-column>
        <el-table-column align="center" label="UID" width="130">
          <template slot-scope="scope">
            {{ scope.row.UID }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="Username" width="350">
          <template slot-scope="scope">
            {{ scope.row.username }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="Game ID" width="350">
          <template slot-scope="scope"> {{ scope.row.usernick }} </template>
        </el-table-column>
        <el-table-column label="Authorization type" width="110" align="center">
          <template slot-scope="scope">
            <el-tag :type="scope.row.authorizationType | tagTypeFilter">{{
              scope.row.authorizationType | authorizationTypeFilter
            }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column align="center" label="Number of successful invitations" width="150">
          <template slot-scope="scope">{{ scope.row.successNum }} </template>
        </el-table-column>
        <!-- <el-table-column align="center" label="Operation" width="150">
          <template slot-scope="scope">
            <el-button
              type="primary"
              size="mini"
              @click="change(scope.$index, scope.row)"
            >
              Modify</el-button>
          </template>
        </el-table-column> -->
      </el-table>
      <!-- Paginator -->
      <div class="block" style="margin-top: 15px">
        <el-pagination
          align="right"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-size="pageSize"
          layout="prev, pager, next, total"
          background
          :total="filterList.length"
          hide-on-single-page
        >
        </el-pagination>
</div>

Here is the javascript part:

export default{
    data(){
        return {
            currentPage:1//Current page number pageSize:10//Number of items to be displayed per page list:[]//Table data to be displayed}
        }
 
    methods{
            handleCurrentChange(val) {
            this.currentPage = val;
        },
    }
 
}

Achieve the effect as shown in the figure

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Table paging function implemented by Vue2.0+ElementUI+PageHelper
  • Vue+ElementUI table realizes table paging
  • Vue+Element UI+Lumen implements universal table paging function
  • How to use vue + element to implement table paging and front-end search
  • Combining Vue Cli with BootStrap to implement table paging function
  • Javascript vue.js table paging, ajax asynchronous loading of data
  • Vue.js table paging ajax asynchronous loading of data
  • Vue.js table paging example
  • Table paging component based on Vue.js

<<:  Steps to build a file server using Apache under Linux

>>:  HTML table tag tutorial (44): table header tag

Recommend

How to configure nginx to limit the access frequency of the same IP

1. Add the following code to http{} in nginx.conf...

Analysis of Linux kernel scheduler source code initialization

Table of contents 1. Introduction 2. Basic Concep...

Implementation of Docker deployment of SQL Server 2019 Always On cluster

Table of contents Docker deployment Always on clu...

Understand the initial use of redux in react in one article

Redux is a data state management plug-in. When us...

Simple implementation of html hiding scroll bar

1. HTML tags with attributes XML/HTML CodeCopy co...

How to deeply understand React's ref attribute

Table of contents Overview 1. Creation of Refs ob...

Use nginx to configure domain name-based virtual hosts

1. What is a virtual host? Virtual hosts use spec...

Complete steps to use vue-router in vue3

Preface Managing routing is an essential feature ...

MySQL uses custom functions to recursively query parent ID or child ID

background: In MySQL, if there is a limited level...

How to use CSS3 to implement a queue animation similar to online live broadcast

A friend in the group asked a question before, th...

WeChat applet implements login interface

The login interface of WeChat applet is implement...

The latest Linux installation process of tomcat8

Download https://tomcat.apache.org/download-80.cg...

Detailed explanation of Nginx reverse proxy example

1. Reverse proxy example 1 1. Achieve the effect ...