时间:2021-07-01 10:21:17 帮助过:5人阅读
本文主要介绍基于vue的分页原生写法。
先po上效果图:

html部分,将page作为一个单独的组件
<script type="text/x-template" id="page">
<ul class="pagination">
<li v-show="current != 1" @click="current-- && goto(current)">
<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" >上一页</a>
</li>
<li v-for="index in pages" @click="goto(index)" :class="{'active':current == index}" :key="index">
<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" >{{index}}</a>
</li>
<li v-show="allpage != current && allpage != 0 " @click="current++ && goto(current++)">
<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" >下一页</a>
</li>
</ul>
</script>
<p id="app">
<page></page>
</p>js部分:
css部分:
body {
font-family: "Segoe UI";
}
li {
list-style: none;
}
a {
text-decoration: none;
}
.pagination {
position: relative;
}
.pagination li {
display: inline-block;
margin: 0 5px;
}
.pagination li a {
padding: .5rem 1rem;
display: inline-block;
border: 1px solid #ddd;
background: #fff;
color: #0E90D2;
}
.pagination li a:hover {
background: #eee;
}
.pagination li.active a {
background: #0E90D2;
color: #fff;
}上面是我整理给大家的,希望今后会对大家有帮助。
相关文章:
Angularjs实现控制器之间通信方式实例总结
Angular中使用better-scroll插件的方法_AngularJS
使用node打造自己的命令行工具方法教程
以上就是基于vue.js实现的分页的详细内容,更多请关注Gxl网其它相关文章!