Before, when I was writing code , There will be many pages table Exhibition , Yes table Paging is also essential , and element-ui The grouping component of provides four events , And so many parameters , If every page is written down , Reusability is too low , Convenient and unified style , Good maintenance . Especially after more methods , The code is very miscellaneous .
edition :element-ui 2.13.1
vue 2.6.11

Event name Description callback parameter
size-changepageSize The number of items per page will be triggered when changing
current-changecurrentPage Changes trigger the current page
prev-click Triggered when the user clicks the previous page button to change the current page Changes trigger the current page
next-click The current page will be triggered after the user clicks the next page button to change the current page
The first step , Package components , Put forward the attributes you need .
<template> <div class="pagination"> <el-pagination
@current-change="handleCurrentChange" @size-change="handleSizeChange"
:page-sizes="pageSizesArr" :total="total" :current-page="currentPage"
:page-size="pageSize" :layout="layout" ></el-pagination> </div> </template>
<script> export default { name: "Pagination", props: { // PageCount total: { type:
Number, default: 0 }, // Current page currentPage: { type: Number, default: 1 }, //
Number of items per page pageSize: { type: Number, default: 10 }, pageSizesArr: { type: Array,
default() { return [10, 20, 30, 50]; } }, layout: { type: String, default:
"total, sizes, prev, pager, next, jumper" } }, data() { return { page: {
_pageSize: this.pageSize, _currentPage: this.currentPage } }; }, methods: { //
Changes in the number of views per page handleSizeChange(val) { console.log(val); = val;
this.$emit("pageChange",; }, // Current page number change handleCurrentChange(val) { = val; this.$emit("pageChange",; } } };
</script> <style scoped lang="scss"> .pagination { margin: 20px 0; } </style>
<Pagination :total="total" :pageNum="pageNum" :pageSize="pageSize"
@pageChange="pageChange"/> import Pagination from
"@/components/Pagination/index"; components: { Pagination },
data() { return { articleList: [], pageSize: 10, pageNum: 1, total: 0 }; },
pageChange(page) { this.pageSize = page._pageSize; this.pageNum =
page._currentPage; this.getData(); },

©2019-2020 Toolsou All rights reserved,
Non preemptive static priority scheduling algorithm for operating system (C language )Go Language learning notes (GUI programming )XCTF Attack and defense world web Advanced practice _ 2_lottery What's the difference between computer major and training background ?python realization vlookup_ Dry goods I : Why python It's inside vlookup Bubble sort primary springboot2 Separation of front and rear platforms ,token Put in header Pit for verification Python Case conversion of letters ( Two methods )javascript event ( Detailed explanation of zero basis )Unity2019 UIElement note ( ten ) Simple exercise 2