Vue.js結合bootstrap實現的分頁控制元件
阿新 • • 發佈:2019-01-22
原文地址:http://blog.csdn.net/qiuhaotc/article/details/53031884
使用 vue.js 結合 bootstrap 開發的分頁控制元件
效果如下
實現程式碼
[html] view plain copy print?- <!DOCTYPE html>
- <html>
- <head>
- <metacharset="utf-8"/>
-
<metaname="viewport"content="width=device-width, initial-scale=1.0"
- <title> Vue-PagerTest</title>
- <linkrel="stylesheet"href="../lib/bootstrap/dist/css/bootstrap.css"/>
- </head>
- <body>
- <divclass="container body-content">
- <divid="test"class="form-group">
- <divclass="form-group">
-
<
- 資料
- </div>
- <tableclass="table table-bordered table-responsive table-striped">
- <tr>
- <th>姓名</th>
- <th>年齡</th>
-
<
- </tr>
- <trv-for="item in arrayData">
- <tdclass="text-center">{{item.name}}</td>
- <td>{{item.age}}</td>
- <td><ahref="javascript:void(0)"v-on:click="deleteItem($index,item.age)">del</a></td>
- </tr>
- </table>
- <divclass="page-header">分頁</div>
- <divclass="pager"id="pager">
- <spanclass="form-inline">
- <selectclass="form-control"v-model="pagesize"v-on:change="showPage(pageCurrent,$event,true)" number>
- <optionvalue="10">10</option>
- <optionvalue="20">20</option>
- <optionvalue="30">30</option>
- <optionvalue="40">40</option>
- </select>
- </span>
- <templatev-for="item in pageCount+1">
- <spanv-if="item==1"class="btn btn-default"v-on:click="showPage(1,$event)">
- 首頁
- </span>
- <spanv-if="item==1"class="btn btn-default"v-on:click="showPage(pageCurrent-1,$event)">
- 上一頁
- </span>
- <spanv-if="item==1"class="btn btn-default"v-on:click="showPage(item,$event)">
- {{item}}
- </span>
- <spanv-if="item==1&&item<showPagesStart-1"class="btn btn-default disabled">
- ...
- </span>