欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue分頁(yè)插件的使用方法

 更新時(shí)間:2019年12月25日 08:56:03   作者:92.4  
這篇文章主要介紹了vue分頁(yè)插件的使用方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue分頁(yè)插件的具體代碼,供大家參考,具體內(nèi)容如下

分頁(yè)插件代碼:

<div>
  <div class="page">
   <div class="pagelist">
      <span class="jump" :class="{disabled:pstart}" @click="lessPage()">上一頁(yè)</span>
      <span v-show="current_page>5" class="jump" @click="jumpPage(1)">1</span>
      <span class="ellipsis" v-show="efont">...</span>
      <span class="jump" v-for="num in indexs" :class="{bgprimary:current_page==num}"
        @click="jumpPage(num)">{{num}}</span>
      <span class="ellipsis" v-show="ebehind">...</span>
 
      <span :class="{disabled:pend}" class="jump" @click="addPage()">下一頁(yè)</span>
      <span v-show="current_page<pages-4" class="jump" @click="jumpPage(pages)">{{pages}}</span>
 
     <#--<span class="jumppoint">跳轉(zhuǎn)到:</span>-->
     <#--<span class="jumpinp"><input type="text" v-model="changePage"></span>-->
     <#--<span class="jump gobtn" @click="jumpPage(changePage)">GO</span>-->
   </div>
  </div>
</div>

vue代碼

data: {
  current_page: result.resultObj.number + 1, //當(dāng)前頁(yè)
  pages: result.resultObj.totalPages, //總頁(yè)數(shù)
  changePage: '',//跳轉(zhuǎn)頁(yè)
  nowIndex: 0
    },
  computed: {
    show: function () {
     return this.pages && this.pages != 1
   },
  pstart: function () {
    return this.current_page == 1;
   },
  pend: function () {
    return this.current_page == this.pages;
     },
   efont: function () {
    if (this.pages <= 7) return false;
      return this.current_page > 5
     },
   ebehind: function () {
      if (this.pages <= 7) return false;
      var nowAy = this.indexs;
      return nowAy[nowAy.length - 1] != this.pages;
     },
    indexs: function () {
 
      var left = 1,
        right = this.pages,
        ar = [];
   if (this.pages >= 7) {
     if (this.current_page > 5 && this.current_page < this.pages -4){
        left = Number(this.current_page) - 3;
        right = Number(this.current_page) + 3;
       } else {
        if (this.current_page <= 5) {
         left = 1;
         right = 7;
        } else {
         right = this.pages;
 
         left = this.pages - 6;
        }
       }
      }
    while (left <= right) {
       ar.push(left);
       left++;
      }
      return ar;
     },
    },
    methods: {
     jumpPage: function (id) {
      if (id <= this.pages && id >= 1) {
       this.current_page = id;
       loadData(this.current_page - 1, size);
      }
     },
    lessPage: function () {
      this.current_page--;
      loadData(this.current_page - 1, size);
     },
    addPage: function () {
      this.current_page++;
      loadData(this.current_page - 1, size);
   }
}

使用說(shuō)明:

直接拷貝即可使用,只需要修改總頁(yè)數(shù)、當(dāng)前頁(yè)。

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

相關(guān)文章

最新評(píng)論