Javascriptvue. js table paging, ajax asynchronously load data

Source: Internet
Author: User
This article mainly introduces Javascriptvue. js table paging: ajax asynchronously loads data related information. If you need it, you can refer to the following pages for use with the table. The paging link is used as part of the table, it is reasonable to encapsulate the paging link into an independent component and embed it into the table component as a child component.

Effect:

Code:

1. Register a component

Js

Vue. component ('pagination', {template: '# paginationTpl', replace: true, props: ['cur', 'all', 'pagenum'], methods: {// page number Click Event btnClick: function (index) {if (index! = This. cur) {this. cur = index ;}}, watch: {"cur": function (val, oldVal) {this. $ dispatch ('page-to ', val) ;}, computed: {indexes: function () {var list = []; // calculate the left and right page numbers var mid = parseInt (this. pageNum/2); // The median value var left = Math. max (this. cur-mid, 1); var right = Math. max (this. cur + this. pageNum-mid-1, this. pageNum); if (right> this. all) {right = this. all} while (left <= right) {list. push (lef T); left ++;} return list;}, showLast: function () {return this. cur! = This. all ;}, showFirst: function () {return this. cur! = 1 ;}}});

Template:

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.