After deleting the current page to load before a unique data content

tips: vue environment

Will speak about ideas.
Get a list of data interfaces, the default background back returns an array that we need to render data on a page, and the other is the total (total), used for paging component displays how many total data.
We need a paging component value is the current size of the paging component (a display how many pieces of data) will use the example code pageSize instead.
We will delete default after each successful request to re-list data back again.
When I started the page is loaded, to get the total number of returned data back, and then declare the two variables in the data, the numeric types.

method:{
 getList(pageNumber ){
  let params ={
     pageNumber: pageNumber ? pageNumber : this.page.current,
     // other content slightly
    }
     Transmission request .then (data => {
       this.getList = data.list // returns the contents
       this.page.total = data.count; // Number of returned by the backend
 
        this.afterPage= Math.floor(this.page.total / this.page.size);
         All data values ​​/ page and go on to the integer
        this.nowSize= this.page.total % this.page.size;
         All data values ​​last page of the remainder of the page size in addition to the number of data
    })

  // delete events
       Deletion request sending .then (() => {
       if(this.nowSize ='1' && this.afterPage>='0'){
           this.getList(this.afterPage)
        }else {
           this.getList()
        }
   })
}

  Since I prefer to afterPage is rounded down, it is needed when the data does not require a previous request -1, but when I 1 current page, my afterPage is 0, and the background in order to prevent the incoming I pageNumer = 0, add a layer of judgment. Where else to go directly to the event can be a ~

Guess you like

Origin www.cnblogs.com/JiAyInNnNn/p/11343799.html