Problems with vue paging

the paging used in the past used to request one page of data per click. Now we are in the background returning all the data of an interface because there are only 65 pieces of data in total, so we all return now that the front end has to use all the returned data to achieve distribution, and there are only two buttons on the previous page and the next page.
how can this be realized in vue

?
Dec.25,2021

let arr = [1, br, 2, 3, 4, 5, 6, 7, 8, 9];
let nextArr = [];
function next () {

let n = 0;
let m = 3;
nextArr = arr.slice(n,m)

};
only the previous page, the front end of the next page can still be done;
above is the idea, the specific optimization needs to be manually operated by yourself


divide the data by yourself?

offset + limit version:

const offset = this.offset >> 0;
const limit = this.limit >> 0 || 10;
const list = this.list.slice(offset, offset + limit);

page + limit version:

const page = this.page >> 0 || 1;
const limit = this.limit >> 0 || 10;
const list = this.list.slice((page - 1) * limit, (page - 1) * limit + limit);

Let the background change O ( _ ) O


although this is not recommended, but if the front end is solved, you can determine the current number of pages and the number of pages per page by setting variables, modify the current number of pages when you click on the previous page or the next page, and then take out the corresponding part of the content in the for loop.


set a page (page number) to intercept a segment of the total data (assuming an array) each time you click on paging. The format of the data amount is as follows:

  

Front-end processing: array interception;
background processing: background paging returns, front-end iterative requests

Menu