最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

element表格翻頁(yè)第2頁(yè)從1開(kāi)始編號(hào)(后端從0開(kāi)始分頁(yè))

 更新時(shí)間:2019年12月10日 14:21:51   作者:溫言  
這篇文章主要介紹了element表格翻頁(yè)第2頁(yè)從1開(kāi)始編號(hào)(后端從0開(kāi)始分頁(yè)),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧

項(xiàng)目中常見(jiàn)的分頁(yè)顯示,第二頁(yè)從1開(kāi)始編號(hào),然后在切換分頁(yè)的過(guò)程中,偶現(xiàn)不對(duì),都是小問(wèn)題,整理記錄一下,供參考。
template:

...
<el-table-column 
type="index" 
label="編號(hào)"
:index="getIndex"
width="80px">
 </el-table-column>
...
<Pagination
  :total="total"
  :pageSize="pageSize"
  :currentPage="currentPage"
  @sizeChange="sizeChange"
  @currentChange="currentChange">
</Pagination>

script:

 getIndex (index) {
  if (this.currentPage==0){
    return (this.currentPage) * this.pageSize + index + 1
  } else{
    return (this.currentPage-1) * this.pageSize + index + 1
  }
 },

由于后端第一頁(yè)是從0開(kāi)始的,而前端是從第一頁(yè)開(kāi)始,所以需要在當(dāng)前頁(yè)減1。關(guān)于分頁(yè),本頁(yè)條數(shù)

sizeChange(val){
  let that = this;
  that.currentPage = 1;
  that.pageSize = val;
  that.getPageInfo(that.currentPage, val);
},

跳轉(zhuǎn)頁(yè)面

currentChange(val){
  let that = this;
  that.currentPage = val;
  that.getPageInfo(val, that.pageSize);
},

頁(yè)面加載數(shù)據(jù)

getUserList(currentPage, pageSize){
  let that = this;
  that.$axios({
   method: 'get',
   url: '***',
   params: {
    currentPage: (currentPage || that.currentPage || 1)-1,
    pageSize: pageSize || that.pageSize || 10
   },
   needInterceptors: true,
   showError: true,
   loader: true
  }).then(function(result){
   let data = result && result.data || [];
   let page = result && result.pageCont || {};
   that.total = page.totalItems || 0;
   that.tableData = data;
  })
 },

試了幾次,這樣寫(xiě)應(yīng)該是沒(méi)有問(wèn)題的,也解決了后端傳0開(kāi)始的問(wèn)題。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

两当县| 承德市| 商洛市| 南郑县| 平乐县| 长沙县| 桂平市| 定远县| 德兴市| 康保县| 中山市| 奈曼旗| 万山特区| 新巴尔虎右旗| 中山市| 青河县| 灵武市| 东平县| 玉溪市| 阳曲县| 北宁市| 博罗县| 盐边县| 井研县| 呼图壁县| 滦南县| 军事| 和龙市| 洛隆县| 阿克苏市| 敦煌市| 巨野县| 渑池县| 江源县| 图片| 大田县| 汤阴县| 杭州市| 上饶县| 宜宾市| 西青区|