基于vue實現(xiàn)分頁效果
更新時間:2017年11月06日 11:55:47 作者:匿名的girl
這篇文章主要介紹了基于vue實現(xiàn)分頁效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了vue實現(xiàn)分頁效果展示的具體代碼,供大家參考,具體內(nèi)容如下
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>分頁練習</title>
<script src="js/vue.js"></script>
</head>
<style>
.isList{
list-style:none;
}
.isPadding{
margin:5px;
padding:5px;
border:2px solid gray;
}
.isRed{
color:red;
}
</style>
<body>
<div id="container">
<p>{{msg}}</p>
<ul v-bind:class="{isList:listStyle}">
<li v-for="(tmp,index) in pageNumbers"
v-bind:style="{float:isFloat}"
v-bind:class="{isPadding:isStyle,isRed:index==pageOne}"
@click="changeBg(index)">{{tmp}}</li>
</ul>
</div>
<script>
new Vue({
el:"#container",
data:{
msg:"Hello VueJs",
listStyle:true,
isFloat:"left",
isStyle:true,
pageNumbers:[1,2,3,4,5],
pageOne:0
},
methods:{
changeBg:function(myIndex){
this.pageOne = myIndex;
}
}
})
</script>
</body>
</html>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
ul {
list-style:none;
}
li{
padding:10px;
margin:5px;
border:1px solid gray;
float:left;
}
.isRed{
color:red;
}
</style>
<script src="js/vue.js"></script>
</head>
<body>
<div id="container">
<p>{{msg}}</p>
<ul>
<li v-for="(tmp,index) in pageNumbers" v-bind:class="{isRed:index==pageNo}" @click="handleClick(index)">{{tmp}}</li>
</ul>
</div>
<script>
new Vue({
el:"#container",
data:{
msg:"Hello VueJs",
pageNumbers:[1,2,3,4,5],
pageNo:0
},
methods:{
handleClick:function(myIndex){
this.pageNo = myIndex;
}
}
})
</script>
</body>
</html>
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Vue使用.sync 實現(xiàn)父子組件的雙向綁定數(shù)據(jù)問題
這篇文章主要介紹了Vue使用.sync 實現(xiàn)父子組件的雙向綁定數(shù)據(jù),需要的朋友可以參考下2019-04-04
Element-ui DatePicker顯示周數(shù)的方法示例
這篇文章主要介紹了Element-ui DatePicker顯示周數(shù)的方法示例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2019-07-07

