Vue project realizes paging effect

Vue project realizes paging effect

The paging effect is implemented in the vue project for your reference. The specific contents are as follows

1. Here we use element-ui to implement it. First install it using npm

npm i element-ui -S

2. Globally import in main.js

import ElementUI from "element-ui"
import 'element-ui/lib/theme-chalk/index.css'

Vue.use(ElementUI) //Hang element-ui globally

3. Packaging components

<template>
 <div class="block">
 <el-pagination
  @current-change="handleCurrentChange"
  :current-page="currentPage"
  :page-size="6"    
  layout="prev, pager, next, jumper"
  :total="total"
  :pager-count="5"
 >
 </el-pagination>
 </div>
</template>

<script>
export default {
 props: ["num", "page"], //The total number of entries passed in, and the page number data() {
 return {};
 },
 computed: {
 currentPage: function() {
  return this.page;
 },
 total: function() {
  return this.num;
 }
 },
 methods: {
 handleSizeChange(val) {
  this.$emit("size-change", val);
 },
 handleCurrentChange(val) {
  this.$emit("current-change", val);
 }
 }
};
</script>

<style>
.block {
 text-align: right;
 /* width: 100%; */
}
</style>

4. Import components and use them

<template>
 <div class="mobild">
  <div>
  <ATablePaging
   :num="num"
   :page="page"
   @current-change="(val) => { 
   page = val;
   list();
   }"
  ></ATablePaging>
  </div>
 </div>
</template>

<script>
import ATablePaging from "../paging"; //Introduce the paging component export default {
 data() {
 return {
  page:"", //Current page number num: 1, //Total number of content items};
 },
 methods: {
 list() {
  //The total number of pages returned by the backend is equal to num
 },
 },
 mounted() {
 this.news();
 },
 components:
 ATablePaging
 }
};
</script>

<style scoped>
</style>

Regarding the learning tutorial of vue.js, please click on the special topics vue.js component learning tutorial and Vue.js front-end component learning tutorial for learning.

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:
  • Vue form form submission + ajax asynchronous request + paging effect
  • Vue.js implements paging query function
  • Example code for writing a pager with Vue
  • Vue.js realizes infinite loading and paging function development
  • Vue.js table paging example
  • VUE+SpringBoot implements paging function
  • Vue component library ElementUI realizes the paging effect of table list
  • How to use ElementUI pagination component Pagination in Vue
  • Vue+iview realizes paging and query functions
  • Encapsulation of vue+iview paging component
  • Vue implements paging function

<<:  Diagram of the process from uninstallation to installation of MySQL 5.7.18 yum under Linux

>>:  Detailed explanation of Nginx proxy_redirect usage

Recommend

React+axios implements github search user function (sample code)

load Request Success Request failed Click cmd and...

CSS realizes the mask effect when the mouse moves to the image

1. Put the mask layer HTML code and the picture i...

Example code for implementing dynamic skinning with vue+element

Sometimes the theme of a project cannot satisfy e...

How to build LNMP environment on Ubuntu 20.04

Simple description Since it was built with Centos...

How to enable remote access in Docker

Docker daemon socket The Docker daemon can listen...

How to implement blank space in Taobao with CSS3

Make a blank space for Taobao: When you shrink th...

Detailed explanation of Truncate usage in MySQL

Preface: When we want to clear a table, we often ...

Detailed explanation of using Vue custom tree control

This article shares with you how to use the Vue c...

Application and implementation of data cache mechanism for small programs

Mini Program Data Cache Related Knowledge Data ca...

The principle and basic use of Vue.use() in Vue

Table of contents Preface 1. Understanding with e...

Implementation of waterfall layout + dynamic rendering

Table of contents Typical waterfall website Water...

Docker installs Elasticsearch7.6 cluster and sets password

Starting from Elasticsearch 6.8, free users are a...

Linux uses lsof command to check file opening status

Preface We all know that in Linux, "everythi...

Several common methods of CSS equal height layout

Equal height layout Refers to the layout of child...