Vue2.0, ElementUI implements table page turning
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>
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, } },
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; } }
The above two responses Function is easy to understand.
<el-table :data="data.slice((currentPage-1)*pagesize,currentPage*pagesize)" stripe style="width: 100%">
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>
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 methodThe 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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



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.

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

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 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的表单验证时都遇到哪些坑,顺便记录分享一下?感兴趣的朋友下面一起来看一下吧,希望对大家有帮助。

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

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.

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
