Home Web Front-end JS Tutorial Vue2.0, ElementUI implements table page turning

Vue2.0, ElementUI implements table page turning

Jan 04, 2018 am 10:21 AM
elementui Turn page

This article mainly brings you an example of Vue2.0+ElementUI realizing table page turning. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor to take a look, I hope it can help everyone.

The data type required by the ElementUI table is a dictionary array. I used python3 to write the backend, so when fetching data from the database, just add a line of cursorclass=pymysql.cursors.DictCursor. After taking it out, I stored it in the redis database for easy access later. When retrieving, just use the eval() function and then pass it to the front end.

Place the Pagination pager on the front end. I directly use the full-featured pager here.


<el-pagination
 @size-change="handleSizeChange" 
 @current-change="handleCurrentChange" 
 :current-page="currentPage" 
 :page-sizes="[10, 20, 50, 100]" 
 :page-size="pagesize" 
 layout="total, sizes, prev, pager, next, jumper" 
 :total="data.length"> 
</el-pagination>
Copy after login

Among them: handleSizeChange is the corresponding function when pagesize changes, and handleCurrentChange is the corresponding function when currentPage changes.

page-sizes are all selectable page-sizes. You can change the numbers yourself.

Layout is an included function, generally you don’t need to touch it.

total is the total number of data. Since it is a dictionary array, you can directly use the length method to get the total number of data.


data () { 
 return { 
 data: [], 
 currentPage:1, 
 pagesize:20, 
 
 } 
},
Copy after login

Initial page currentPage, initial number of data per page pagesize and data data


 methods: { 
 handleSizeChange: function (size) { 
 this.pagesize = size; 
 }, 
 handleCurrentChange: function(currentPage){ 
 this.currentPage = currentPage; 
 } 
}
Copy after login

The above two responses Function is easy to understand.


<el-table
 :data="data.slice((currentPage-1)*pagesize,currentPage*pagesize)" 
 stripe 
 style="width: 100%">
Copy after login

el-table tag. It is easy to get through calculation. To make the page display the corresponding data after paging, the subscript should be (current page-1)*number of data per page to current page*number of data per page. Use the slice method to retrieve.

stripe is a table with zebra pattern.


<el-table-column
 prop="id" 
 label="序号" 
 align="center"> 
</el-table-column>
Copy after login

column tag. Multiple items can be placed to control each column. label is the name of the column, displayed in the first row. prop is the name of a key in data.

Final result.

Related recommendations:

Use VUE element-ui to write a reusable Table component

About vueElement-ui input search Let’s talk about the tree component element ui

with the modification method

The above is the detailed content of Vue2.0, ElementUI implements table page turning. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use style penetration to modify elementUI default style in vue3 project How to use style penetration to modify elementUI default style in vue3 project May 12, 2023 pm 02:34 PM

1. Style modularization In a single CSS file, we write the style of the component in the style tag. You can see that generally the style tag will have a scoped attribute. This can achieve the same selector for different components in real time, but the styles will not interfere with each other. . Let's look at an example. We define a hello-world-box class in both components and set different styles in the corresponding scope tags. As you can see, vue adds a unique attribute (PostCSS translation implementation) to the labels in different components. Then, through the attribute selector, the label styles of different attributes do not interfere with each other. The role of the css attribute selector is to set styles for HTML elements with specific attributes.

How to turn pages in word How to turn pages in word Mar 19, 2024 pm 07:22 PM

Word is one of the commonly used office software. When the edited text content is long and difficult to read, you can turn pages in Word. Below, the editor will share with my friends a simple tutorial on how to turn pages in Word! Hope this helps you guys! 1. First, we open the multi-page word document in word software on the computer. As shown in the picture below: 2. Click the upward arrow on the scroll bar of the word interface to scroll up and turn pages. As shown in the picture below: 3. If you need to page down, click the downward arrow of the scroll bar. As shown in the picture below: 4. Click the arrow of the scroll bar to turn pages. This kind of page turning is more casual. We need to quickly turn pages by using the right mouse button to click on the scroll bar. as follows

How to use elementUI+Springboot to implement the excel export function How to use elementUI+Springboot to implement the excel export function May 18, 2023 pm 07:19 PM

Step Dependency Package First, we need to introduce the dependency package of vue. I use this npminstallxlsx@^0.16.0npminstallfile-saver@^2.0.2. The function of the xlsx dependency is to process the data into an excel workbook file-saver dependency. The function is: save the file and export it to the element table. Here, the table tag of elementenetUI is actually used to obtain the data. Therefore, we need to add a selector to the table. In my project, I added An id: exportExceltableData is passed to the custom receiving backend.

How to use JavaScript to implement infinite scrolling? How to use JavaScript to implement infinite scrolling? Oct 19, 2023 am 09:57 AM

How to use JavaScript to implement infinite scrolling page turning function? Infinite scrolling has become very popular in modern website design. This feature helps users scroll the page to load new content without having to click the page button. In this article, we will introduce how to use JavaScript to implement infinite scrolling and provide specific code examples. To implement infinite scrolling page turning function, we need to listen to user scroll events and load new content when the page scrolls to a specific position.

总结elementUI表单验证的踩坑解决方法 总结elementUI表单验证的踩坑解决方法 Mar 17, 2023 pm 04:22 PM

本篇文章给大家带来了关于elementUI的相关知识,其中主要跟大家聊一聊我在实现elementUI的表单验证时都遇到哪些坑,顺便记录分享一下?感兴趣的朋友下面一起来看一下吧,希望对大家有帮助。

How Vue+ElementUI implements paging function to query mysql data How Vue+ElementUI implements paging function to query mysql data Jun 01, 2023 pm 04:19 PM

1. Problem When there is a lot of data in the database, it is necessary to query only part of it at a time to relieve the pressure on the server and the page. Here we use elementui's Pagination component and cooperate with mysql's limit statement to realize paging query of mysql data. The following figure is the most basic paging style: Of course, corresponding events need to be introduced to query the database when the page changes. 2. Solve 2.1 paging component data: initialize the total number of data items (total) to 1, and pageNum, which is the current page number, is the first page. 2.2 Function to obtain database data: getData(): The parameters are offset and limit, requesting data from the backend, which will be explained later. qs is used here

What are the basic knowledge of Vue+ElementUI+Springboot What are the basic knowledge of Vue+ElementUI+Springboot May 25, 2023 pm 11:26 PM

1. Web backend in the old world (1) At the beginning, web backends were basically written in PHP, a scripting language that was very convenient to embed into HTML. (2) Then Java began to gain momentum, and JSP+Servlet became mainstream. (3) I found that Java was smelly and long, so I started to encapsulate some commonly used ideas into classes, so Spring grew up and had two core concepts: AOP aspects and IoC control inversion. These two ideas are simply invincible. AOP: For example, exceptions may be thrown in every place in our program. In the past, it was very cumbersome to try and catch in every place, and the post-catch processing was similar. If there is an aspect that intercepts the Web exit, all traffic will pass through this aspect.

Use PHP and WebDriver extensions to implement web page scrolling and page turning tests Use PHP and WebDriver extensions to implement web page scrolling and page turning tests Jul 07, 2023 am 10:19 AM

Test introduction of web page scrolling and page turning using PHP and WebDriver extensions: With the development and popularization of the Internet, the presentation methods of web pages are becoming more and more diverse. In order to ensure that web pages display properly and function properly on different terminals, developers need to conduct various tests. Among them, the test of web page scrolling and page turning is an important test item. This article will introduce how to use PHP and WebDriver extensions to implement web page scrolling and page turning tests, and attach code examples. Prerequisites: Before starting, you need to install

See all articles