search
HomeWeb Front-endLayui TutorialHow to use layui's paging

How to use layui's paging

Jul 11, 2019 am 09:45 AM
layuiPagination

layui is a very practical front-end development library. We can use it to easily and simply create various beautiful front-end UIs. Let's take a brief look at a commonly used paging component and how to use layui to complete it. Just a few lines of code will do.

How to use layui's paging

Method/Step

First we need to introduce the script file and style file corresponding to lay.

How to use layuis paging

In Html, we only need to create an empty div to generate the paging component, and provide an id for this div.

How to use layuis paging

In the js script code, we first generate a laypage paging component instance object.

How to use layuis paging

#Then call the render method of this object to render each element of the paging.

In the render method, we pass in an object, elem is the id of the div.

count is used to indicate how many pieces of data there are in the paging object.

How to use layuis paging

Run this code, we can see the rendered paging. With a very simple code, we can get a beautiful paging.

How to use layuis paging

Related recommendations: "layui framework tutorial"

We can see from the above data that by default it is one page Contains 10 pieces of data.

Of course we can also configure this, just provide the limit parameter, we set it to 4 here.

How to use layuis paging

Refresh the page and you can see that there are 20 pieces of data and 4 rows of data per page. You can see that it is now divided into 5 pages.

How to use layuis paging

#In the paging control, a very important function is the need for interaction, that is, after clicking on a certain page, the data of the corresponding page needs to be displayed.

Therefore, the component provides a jump method for interaction. In this method, a parameter obj will be passed. From this obj, we can get some commonly used data, such as obj.cur, which gets the current page number.

obj.limit can get the number of data contained in each page.

How to use layuis paging

How to use layuis paging

The above is the detailed content of How to use layui's paging. For more information, please follow other related articles on the PHP Chinese website!

Statement
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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment