vue.js 2.0實現(xiàn)簡單分頁效果
更新時間:2019年07月29日 10:36:56 作者:羅兵
這篇文章主要為大家詳細介紹了vue.js 2.0實現(xiàn)簡單分頁效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了vue.js 2.0實現(xiàn)分頁效果的具體代碼,供大家參考,具體內容如下
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>vue.js 2.0 實現(xiàn)的簡單分頁</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box
}
html {
font-size: 12px;
font-family: Ubuntu, simHei, sans-serif;
font-weight: 400
}
body {
font-size: 1rem
}
.text-center{
text-align: center;
}
.pagination {
display: inline-block;
padding-left: 0;
margin: 21px 0;
border-radius: 3px;
}
.pagination > li {
display: inline;
}
.pagination > li > a {
position: relative;
float: left;
padding: 6px 12px;
line-height: 1.5;
text-decoration: none;
color: #009a61;
background-color: #fff;
border: 1px solid #ddd;
margin-left: -1px;
list-style: none;
}
.pagination > li > a:hover {
background-color: #eee;
}
.pagination .active {
color: #fff;
background-color: #009a61;
border-left: none;
border-right: none;
}
.pagination .active:hover {
background: #009a61;
cursor: default;
}
.pagination > li:first-child > a .p {
border-bottom-left-radius: 3px;
border-top-left-radius: 3px;
}
.pagination > li:last-child > a {
border-bottom-right-radius: 3px;
border-top-right-radius: 3px;
}
</style>
</head>
<body>
<div id="app">
<ul class="pagination">
<li v-for="index in all">
<a v-bind:class="cur === index + 1 ? 'active' : ''" v-on:click="btnClick(index + 1)">{{ index + 1 }}</a>
</li>
</ul>
</div>
</body>
<script src="js/vue.js"></script>
<script>
var vm = new Vue({
el: '#app',
data: {
cur: 1, //當前頁碼
all: 8 //總頁數(shù)
},
watch: {
cur: function(newVal, oldVal){ // 數(shù)值產生變化,觸發(fā)回調
console.log(newVal, oldVal);
}
},
methods: {
btnClick: function(i){
this.cur = i;
// ajax 調取數(shù)據(jù)...
}
}
})
</script>
</html>
效果圖

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
Element-ui之ElScrollBar組件滾動條的使用方法
這篇文章主要介紹了Element-ui之ElScrollBar組件滾動條的使用方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-09-09
vue-element如何實現(xiàn)動態(tài)換膚存儲
這篇文章主要介紹了vue-element如何實現(xiàn)動態(tài)換膚存儲問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-04-04
vue+element-ui+ajax實現(xiàn)一個表格的實例
下面小編就為大家分享一篇vue+element-ui+ajax實現(xiàn)一個表格的實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-03-03

