亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Vue.js結(jié)合bootstrap實(shí)現(xiàn)分頁(yè)控件

 更新時(shí)間:2021年08月20日 13:19:03   作者:笑問(wèn)蒼天丶  
這篇文章主要為大家詳細(xì)介紹了Vue.js 合bootstrap實(shí)現(xiàn)分頁(yè)控件的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文為大家分享了使用vue.js結(jié)合bootstrap 開(kāi)發(fā)的分頁(yè)控件,供大家參考,具體內(nèi)容如下

效果如下

實(shí)現(xiàn)代碼:

<!DOCTYPE html> 
<html> 
<head> 
 <meta charset="utf-8" /> 
 <meta name="viewport" content="width=device-width, initial-scale=1.0" /> 
 <title> Vue-PagerTest</title> 
 <link rel="stylesheet" href="/lib/bootstrap/dist/css/bootstrap.css" /> 
</head> 
<body> 
 <div class="container body-content"> 
 <div id="test" class="form-group"> 
  <div class="form-group"> 
  <div class="page-header"> 
   數(shù)據(jù) 
  </div> 
  <table class="table table-bordered table-responsive table-striped"> 
   <tr> 
   <th>姓名</th> 
   <th>年齡</th> 
   <th>刪除信息</th> 
   </tr> 
   <tr v-for="item in arrayData"> 
   <td class="text-center">{{item.name}}</td> 
   <td>{{item.age}}</td> 
   <td><a href="javascript:void(0)" rel="external nofollow" v-on:click="deleteItem($index,item.age)">del</a></td> 
   </tr> 
  </table> 
  <div class="page-header">分頁(yè)</div> 
  <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> 
   <template v-for="item in pageCount+1"> 
   <span v-if="item==1" class="btn btn-default" v-on:click="showPage(1,$event)"> 
    首頁(yè) 
   </span> 
   <span v-if="item==1" class="btn btn-default" v-on:click="showPage(pageCurrent-1,$event)"> 
    上一頁(yè) 
   </span> 
   <span v-if="item==1" class="btn btn-default" v-on:click="showPage(item,$event)" v-bind:class="item==pageCurrent?'active':''"> 
    {{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)" <span style="font-family: Arial, Helvetica, sans-serif;"> v-bind:class="item==pageCurrent?'active':''"</span><span style="font-family: Arial, Helvetica, sans-serif;">></span> 
    {{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)" <span style="font-family: Arial, Helvetica, sans-serif;">v-bind:class="item==pageCurrent?'active':''"</span><span style="font-family: Arial, Helvetica, sans-serif;">></span> 
    {{item}} 
   </span> 
   <span v-if="item==pageCount" class="btn btn-default" v-on:click="showPage(pageCurrent+1,$event)"> 
    下一頁(yè) 
   </span> 
   <span v-if="item==pageCount" class="btn btn-default" v-on:click="showPage(pageCount,$event)"> 
    尾頁(yè) 
   </span> 
   </template> 
   <span class="form-inline"> 
   <input class="pageIndex form-control" style="width:60px;text-align:center" type="text" v-model="pageCurrent | onlyNumeric" v-on:keyup.enter="showPage(pageCurrent,$event,true)" /> 
   </span> 
   <span>{{pageCurrent}}/{{pageCount}}</span> 
  </div> 
  </div> 
 </div> 
 <hr /> 
 <footer> 
  <p>&copy; 2016 - 笑問(wèn)蒼天丶</p> 
 </footer> 
 </div> 
 
 
 <script src="/lib/jquery/dist/jquery.js"></script> 
 <script src="/lib/bootstrap/dist/js/bootstrap.js"></script> 
 <script src="/lib/vue.js"></script> 
 <script> 
 //只能輸入正整數(shù)過(guò)濾器 
 Vue.filter('onlyNumeric', { 
  // model -> view 
  // 在更新 `<input>` 元素之前格式化值 
  read: function (val) { 
  return val; 
  }, 
  // view -> model 
  // 在寫(xiě)回?cái)?shù)據(jù)之前格式化值 
  write: function (val, oldVal) { 
  var number = +val.replace(/[^\d]/g, '') 
  return isNaN(number) ? 1 : parseFloat(number.toFixed(2)) 
  } 
 }) 
 
 //數(shù)組刪除某項(xiàng)功能 
 Array.prototype.remove = function (dx) { 
  if (isNaN(dx) || dx > this.length) { return false; } 
  for (var i = 0, n = 0; i < this.length; i++) { 
  if (this[i] != this[dx]) { 
   this[n++] = this[i] 
  } 
  } 
  this.length -= 1 
 } 
 
 var vue = new Vue({ 
  el: "#test", 
  data: { 
  //總項(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: { 
  //分頁(yè)方法 
  showPage: function (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; 
   } 
 
   //測(cè)試數(shù)據(jù) 隨機(jī)生成的 
   var newPageInfo = []; 
   for (var i = 0; i < this.pagesize; i++) { 
    newPageInfo[newPageInfo.length] = { 
    name: "test" + (i + (pageIndex - 1) * 20), 
    age: (i + (pageIndex - 1) * 20) 
    }; 
   } 
   this.pageCurrent = pageIndex; 
   this.arrayData = newPageInfo; 
 
   //計(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); 
   } 
 
  } 
  , deleteItem: function (index, age) { 
   if (confirm('確定要?jiǎng)h除嗎')) { 
   //console.log(index, age); 
 
   var newArray = []; 
   for (var i = 0; i < this.arrayData.length; i++) { 
    if (i != index) { 
    newArray[newArray.length] = this.arrayData[i]; 
    } 
   } 
   this.arrayData = newArray; 
   } 
  } 
  } 
 }); 
 vue.$watch("arrayData", function (value) { 
  //console.log("==============arrayData begin=============="); 
  //console.log(value==vue.arrayData); 
  //console.log(vue.arrayData); 
  //console.log("==============arrayData end=============="); 
 }); 
 vue.showPage(vue.pageCurrent, null, true); 
 </script> 
</body> 
</html> 

源碼下載: bootstrap分頁(yè)控件

參考資料: Vue.js官網(wǎng)

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

相關(guān)文章

  • ubuntu中利用nginx部署vue項(xiàng)目的完整步驟

    ubuntu中利用nginx部署vue項(xiàng)目的完整步驟

    Nginx是一款輕量級(jí)的Web服務(wù)器/反向代理服務(wù)器及電子郵件(IMAP/POP3)代理服務(wù)器,在BSD-like 協(xié)議下發(fā)行,下面這篇文章主要給大家介紹了關(guān)于ubuntu中利用nginx部署vue項(xiàng)目的相關(guān)資料,需要的朋友可以參考下
    2022-02-02
  • vue中添加mp3音頻文件的方法

    vue中添加mp3音頻文件的方法

    本篇文章主要介紹了vue中添加mp3音頻文件的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-03-03
  • Vue中webpack的使用詳解

    Vue中webpack的使用詳解

    這篇文章主要為大家詳細(xì)介紹了Vue中webpack的使用,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來(lái)幫助
    2022-03-03
  • vue如何通過(guò)點(diǎn)擊事件實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)詳解

    vue如何通過(guò)點(diǎn)擊事件實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)詳解

    頁(yè)面跳轉(zhuǎn),我們一般都通過(guò)路由跳轉(zhuǎn)實(shí)現(xiàn),通常情況下可直接使用router-link標(biāo)簽實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn),下面這篇文章主要給大家介紹了關(guān)于vue如何通過(guò)點(diǎn)擊事件實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)的相關(guān)資料,需要的朋友可以參考下
    2022-07-07
  • mpvue構(gòu)建小程序的方法(步驟+地址)

    mpvue構(gòu)建小程序的方法(步驟+地址)

    mpvue是一個(gè)使用Vue.js開(kāi)發(fā)小程序的前端框架。框架基于 Vue.js 核心,這篇文章主要介紹了mpvue構(gòu)建小程序的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-05-05
  • Vue實(shí)現(xiàn)簡(jiǎn)單的拖拽效果

    Vue實(shí)現(xiàn)簡(jiǎn)單的拖拽效果

    這篇文章主要為大家詳細(xì)介紹了Vue實(shí)現(xiàn)簡(jiǎn)單的拖拽效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-08-08
  • elementUI select組件value值注意事項(xiàng)詳解

    elementUI select組件value值注意事項(xiàng)詳解

    這篇文章主要介紹了elementUI select組件value值注意事項(xiàng)詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-05-05
  • 詳解使用vue實(shí)現(xiàn)tab 切換操作

    詳解使用vue實(shí)現(xiàn)tab 切換操作

    這篇文章主要介紹了詳解使用vue實(shí)現(xiàn)tab操作,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-07-07
  • vue中關(guān)于el-popover的使用

    vue中關(guān)于el-popover的使用

    這篇文章主要介紹了vue中關(guān)于el-popover的使用方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-04-04
  • vue實(shí)現(xiàn)購(gòu)物車(chē)拋物線小球動(dòng)畫(huà)效果的方法詳解

    vue實(shí)現(xiàn)購(gòu)物車(chē)拋物線小球動(dòng)畫(huà)效果的方法詳解

    這篇文章主要介紹了vue實(shí)現(xiàn)購(gòu)物車(chē)拋物線小球動(dòng)畫(huà)效果的方法,結(jié)合實(shí)例形式較為詳細(xì)的分析了vue.js實(shí)現(xiàn)拋物線動(dòng)畫(huà)效果購(gòu)物車(chē)功能相關(guān)原理與操作注意事項(xiàng),需要的朋友可以參考下
    2019-02-02

最新評(píng)論