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

A brief analysis of the use of zero copy technology in Linux

This article discusses several major zero-copy te...

Summary of Common Mistakes in Web Design

In the process of designing a web page, designers...

Detailed explanation of PHP+nginx service 500 502 error troubleshooting ideas

Overview When a 500 or 502 error occurs during ac...

Detailed explanation of where Docker saves log files

Table of contents Where are the logs stored? View...

Summary of a CSS code that makes the entire site gray

In order to express the deep condolences of peopl...

Detailed explanation of various methods of Vue component communication

Table of contents 1. From father to son 2. From s...

uniapp dynamic modification of element node style detailed explanation

Table of contents 1. Modify by binding the style ...

Vue event's $event parameter = event value case

template <el-table :data="dataList"&...

MySQL spatial data storage and functions

Table of contents 1. Data Type 1. What is MySQL s...

Detailed explanation of MySQL's MERGE storage engine

The MERGE storage engine treats a group of MyISAM...

Design Theory: Hierarchy in Design

<br />Original text: http://andymao.com/andy...

Vue uses filters to format dates

This article example shares the specific code of ...