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

Vue Cli與BootStrap結(jié)合實(shí)現(xiàn)表格分頁(yè)功能

 更新時(shí)間:2017年08月18日 08:38:50   作者:肖爾_  
這篇文章主要介紹了Vue Cli與BootStrap結(jié)合實(shí)現(xiàn)表格分頁(yè)功能,需要的朋友可以參考下

1、首先需要在vue-cli項(xiàng)目中配置bootstrap,jquery

2、 然后新建vue文件,如index.vue,index.vue內(nèi)容如下:

3、配置路由即可運(yùn)行實(shí)現(xiàn)。

<template>
  <div class="tTable container body-content">
    <div class="form-group">
      <div class="form-group">
        <div class="page-header">
          表格
        </div>
        <table class="table table-bordered table-responsive table-striped">
          <thead>
          <tr>
          <th>時(shí)間</th>
          <th>點(diǎn)擊數(shù)</th>
          <th>點(diǎn)擊數(shù)</th>
          </tr>
          </thead>
          <tbody>
          <tr v-for="item in arrayData">
            <td>{{item.timestamp}}</td>
            <td>{{item.count}}</td>
            <td>{{item.count}}</td>
          </tr>
          </tbody>
        </table>
        <div class="pager" id="pager">
          <span class="form-inline">
            <select class="form-control" v-model="pagesize" v-on:change="showPage(pageCurrent,$event,true)" number>
              <option value="10">10</option>
              <option value="20">20</option>
              <option value="30">30</option>
              <option value="40">40</option>
            </select>
          </span>
          <span v-for="item in pageCount+1">
            <span v-if="item==1" class="btn btn-default" v-on:click="showPage(1,$event)" :class="{'disabled':fDisabled}">
              首頁(yè)
            </span>
            <span v-if="item==1" class="btn btn-default" v-on:click="showPage(pageCurrent-1,$event)" :class="{'disabled':fDisabled}">
              上一頁(yè)
            </span>
            <span v-if="item==1" class="btn btn-default" v-on:click="showPage(item,$event)">
              {{item}}
            </span>
            <span v-if="item==1&&item<showPagesStart-1" class="btn btn-default disabled">
              ...
            </span>
            <span v-if="item>1&&item<=pageCount-1&&item>=showPagesStart&&item<=showPageEnd&&item<=pageCount" class="btn btn-default" v-on:click="showPage(item,$event)">
              {{item}}
            </span>
            <span v-if="item==pageCount&&item>showPageEnd+1" class="btn btn-default disabled">
              ...
            </span>
            <span v-if="item==pageCount" class="btn btn-default" v-on:click="showPage(item,$event)" >
              {{item}}
            </span>
            <span v-if="item==pageCount" class="btn btn-default" v-on:click="showPage(pageCurrent+1,$event)" :class="{'disabled':lDisabled}">
              下一頁(yè)
            </span>
            <span v-if="item==pageCount" class="btn btn-default" v-on:click="showPage(pageCount,$event)" :class="{'disabled':lDisabled}">
              尾頁(yè)
            </span>
          </span>
          <span>{{pageCurrent}}/{{pageCount}}</span>
        </div>
      </div>
    </div>
  </div>
 </template>
 <script >
 export default {
  data(){
    return{
         //為第一頁(yè)或者最后一頁(yè)時(shí),首頁(yè),尾頁(yè)不能點(diǎn)擊
        fDisabled:false,
        lDisabled:false,
         //總項(xiàng)目數(shù)
        totalCount: 200,
        //分頁(yè)數(shù)
        pageCount: 20,
        //當(dāng)前頁(yè)面
        pageCurrent: 1,
        //分頁(yè)大小
        pagesize: 10,
        //顯示分頁(yè)按鈕數(shù)
        showPages: 11,
        //開(kāi)始顯示的分頁(yè)按鈕
        showPagesStart: 1,
        //結(jié)束顯示的分頁(yè)按鈕
        showPageEnd: 100,
        //分頁(yè)數(shù)據(jù)
        arrayData: []
    }
  },
  methods:{
    showPage(pageIndex, $event, forceRefresh){
      if (pageIndex > 0) {
        if (pageIndex > this.pageCount) {
          pageIndex = this.pageCount;
        }
        //判斷數(shù)據(jù)是否需要更新
        var currentPageCount = Math.ceil(this.totalCount / this.pagesize);
        if (currentPageCount != this.pageCount) {
          pageIndex = 1;
          this.pageCount = currentPageCount;
        }
        else if (this.pageCurrent == pageIndex && currentPageCount == this.pageCount && typeof (forceRefresh) == "undefined") {
          console.log("not refresh");
          return;
        }
        //處理分頁(yè)點(diǎn)中樣式
        var buttons = $("#pager").find("span");
        for (var i = 0; i < buttons.length; i++) {
          if (buttons.eq(i).html() != pageIndex) {
            buttons.eq(i).removeClass("active");
          }
          else {
            buttons.eq(i).addClass("active");
          }
        }
        //測(cè)試數(shù)據(jù) 隨機(jī)生成的
        var newPageInfo = [];
        var time=new Date();
        for (var i = 0; i < this.pagesize; i++) {
          newPageInfo[newPageInfo.length] = {
            timestamp: time,
            count: (i + (pageIndex - 1) * 20)
          };
        }
        this.pageCurrent = pageIndex;
        this.arrayData = newPageInfo;
        //如果當(dāng)前頁(yè)首頁(yè)或者尾頁(yè),則上一頁(yè)首頁(yè)就不能點(diǎn)擊,下一頁(yè)尾頁(yè)就不能點(diǎn)擊
         if(this.pageCurrent===1){
            this.fDisabled=true;
          }else if(this.pageCurrent===this.pageCount){
            this.lDisabled=true;
          }else{
             this.fDisabled=false;
             this.lDisabled=false;
          }
        //計(jì)算分頁(yè)按鈕數(shù)據(jù)
        if (this.pageCount > this.showPages) {
          if (pageIndex <= (this.showPages - 1) / 2) {
            this.showPagesStart = 1;
            this.showPageEnd = this.showPages - 1;
            console.log("showPage1")
          }
          else if (pageIndex >= this.pageCount - (this.showPages - 3) / 2) {
            this.showPagesStart = this.pageCount - this.showPages + 2;
            this.showPageEnd = this.pageCount;
            console.log("showPage2")
          }
          else {
            console.log("showPage3")
            this.showPagesStart = pageIndex - (this.showPages - 3) / 2;
            this.showPageEnd = pageIndex + (this.showPages - 3) / 2;
          }
        }
        console.log("showPagesStart:" + this.showPagesStart + ",showPageEnd:" + this.showPageEnd + ",pageIndex:" + pageIndex);
      }
    }
  },
  mounted(){
    this.showPage(this.pageCurrent, null, true);
  },
  computed:{
  }
}
 </script>

總結(jié)

以上所述是小編給大家介紹的Vue Cli與BootStrap結(jié)合實(shí)現(xiàn)表格分頁(yè)功能,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • vue使用keep-alive進(jìn)行組件緩存方法詳解(組件不緩存問(wèn)題解決)

    vue使用keep-alive進(jìn)行組件緩存方法詳解(組件不緩存問(wèn)題解決)

    keep-alive包裹動(dòng)態(tài)組件時(shí),會(huì)緩存不活動(dòng)的組件實(shí)例,而不是銷(xiāo)毀它們,下面這篇文章主要給大家介紹了關(guān)于vue使用keep-alive進(jìn)行組件緩存方法(組件不緩存問(wèn)題解決)的相關(guān)資料,需要的朋友可以參考下
    2022-09-09
  • vue之Vue.use的使用場(chǎng)景及說(shuō)明

    vue之Vue.use的使用場(chǎng)景及說(shuō)明

    這篇文章主要介紹了vue之Vue.use的使用場(chǎng)景,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-12-12
  • vue面試??贾甤omputed是如何實(shí)現(xiàn)的

    vue面試常考之computed是如何實(shí)現(xiàn)的

    對(duì)于每天都在用的計(jì)算屬性(computed),小編猜大家肯定也想窺探其奧妙與原理對(duì)吧,所以這篇文章就來(lái)講講computed是如何實(shí)現(xiàn)的吧,感興趣的小伙伴可以學(xué)習(xí)一下
    2023-08-08
  • Vue公共loading升級(jí)版解決思路(處理并發(fā)異步差時(shí)響應(yīng))

    Vue公共loading升級(jí)版解決思路(處理并發(fā)異步差時(shí)響應(yīng))

    這篇文章主要介紹了Vue公共loading升級(jí)版(處理并發(fā)異步差時(shí)響應(yīng)),解決思路是通過(guò)定義一個(gè)全局對(duì)象來(lái)存儲(chǔ)每個(gè)接口的響應(yīng)狀態(tài),直到每個(gè)請(qǐng)求接口都收到響應(yīng)才變更狀態(tài),結(jié)束loading動(dòng)畫(huà),需要的朋友可以參考下
    2023-11-11
  • vue中注冊(cè)自定義的全局js方法

    vue中注冊(cè)自定義的全局js方法

    這篇文章主要介紹了vue中注冊(cè)自定義的全局js方法,文中給大家補(bǔ)充介紹了vue自定義函數(shù)掛到全局的方法,需要的朋友可以參考下
    2019-11-11
  • vue3使用ref和reactive的示例詳解

    vue3使用ref和reactive的示例詳解

    Vue 3引入了兩個(gè)新的API,ref和reactive,用于創(chuàng)建響應(yīng)式對(duì)象,這兩個(gè)方法都位于Vue.prototype上,因此可以在組件實(shí)例中直接使用,本文給大家介紹vue3使用ref和reactive的示例,感興趣的朋友跟隨小編一起看看吧
    2023-10-10
  • vue和better-scroll實(shí)現(xiàn)列表左右聯(lián)動(dòng)效果詳解

    vue和better-scroll實(shí)現(xiàn)列表左右聯(lián)動(dòng)效果詳解

    這篇文章主要介紹了vue和better-scroll實(shí)現(xiàn)列表左右聯(lián)動(dòng)效果,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • 解決vue2中使用axios http請(qǐng)求出現(xiàn)的問(wèn)題

    解決vue2中使用axios http請(qǐng)求出現(xiàn)的問(wèn)題

    下面小編就為大家分享一篇解決vue2中使用axios http請(qǐng)求出現(xiàn)的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-03-03
  • vue增刪改查的簡(jiǎn)單操作

    vue增刪改查的簡(jiǎn)單操作

    這篇文章主要為大家詳細(xì)介紹了vue增刪改查的簡(jiǎn)單操作,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-07-07
  • vuex中的state、getters、mutations、actions之間的關(guān)系解讀

    vuex中的state、getters、mutations、actions之間的關(guān)系解讀

    這篇文章主要介紹了vuex中的state、getters、mutations、actions之間的關(guān)系,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-10-10

最新評(píng)論

平泉县| 雷山县| 光山县| 安西县| 平山县| 太仆寺旗| 池州市| 临颍县| 宾川县| 揭西县| 库车县| 常州市| 织金县| 沭阳县| 尼玛县| 唐海县| 漳州市| 宣武区| 凌云县| 长白| 大庆市| 西安市| 宁城县| 桃源县| 黔南| 武宁县| 梧州市| 白银市| 阜新市| 尉氏县| 宜阳县| 万盛区| 土默特右旗| 县级市| 巴林左旗| 新建县| 黄平县| 嘉善县| 冷水江市| 清水河县| 思茅市|