Use vue and element-ui to set the table content paging instance, vueelement-ui

Source: Internet
Author: User

Use vue and element-ui to set the table content paging instance, vueelement-ui

Html code

Because I wrote it in the template, that is, I created a new group and pasted the code.

<el-pagination  small layout="prev, pager, next" :total="total"  @current-change="current_change"></el-pagination>

In the code, small indicates whether to use a small paging style.

Layout indicates the component layout. Child component names are separated by commas (,).

Attribute: total indicates the total number of items.

Event: current-change is used to listen for page changes, and the content also changes

For other attributes, see the official API of element.

Http://element.eleme.io/#/zh-CN/component/pagination

Listening method, written in methods

Methods: {created: function () {// load the class data var url = 'HTTP: // 127.0.0.1: 3000/clazz/findall '; // obtain data from the background var vm = this; $. getJSON (url, function (data) {vm. clazzInfo = data; vm. total = data. length; // set the total number of Data !!! });}, Current_change: function (currentPage) {this. currentPage = currentPage ;}}

The url is the route set for the scaffold built in the backend express.

Data used for registration in data

Because I registered globally, data is a function that returns objects.

Data: function () {return {total: 0, // default total data pagesize: 7, // number of data entries per page currentPage: 1, // default start page }}

Bind data to tbody

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

SearchInfo is an array of background data that I have obtained.

The above example of using vue and element-ui to set the pagination of table content is all the content shared by Alibaba Cloud. I hope you can provide a reference and support for the customer's home.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.