vue 分页
来源:互联网 发布:录屏软件 编辑:程序博客网 时间:2024/06/11 01:13
仅作为自己学习的记录。
html
<nav class="navigation"> <ul class="pagination"> <li class="Previous" v-on:click="prev">上一页</li> <li> <a href="javascript:void(0);" v-for="item in pages" v-on:click="p(item)" v-bind:class="{nowStyle:page == item}"> {{ item }}</a> </li> <li class="Next" v-on:click="next">下一页</li> </ul></nav>
css
.navigation { display: flex; float: right; padding-top: 15px;}.pagination { display: flex; li{ margin-left: 10px; cursor: pointer; a{ padding: 2px 6px; background: #ededed; margin: 0 4px; } a.nowStyle{ background: #3dbff5; color: #ffffff; } }}
js
export default { data () { return { pages: [], page: 1, } }, created () { // 页面加载时获取页数 var that = this var params = {page: 1} that.$api.post('###', params, function (req) { that.pages = req.content.pages }) }, methods: { // 上一页 prev () { var that = this that.page = that.page - 1 < 1 ? 1 : that.page - 1 that.searchs() }, // 下一页 next () { var that = this that.page = parseInt(that.page) + 1 > that.pages ? that.pages : parseInt(that.page) + 1 that.searchs() }, // 选择第几页 p (p) { var that = this that.page = p that.searchs() }, // 后台获取页数 searchs () { var that = this var params = {page: that.page} that.$api.post('###', params, function (req) { that.pages = req.content.pages }) } }}
跳转页数版本
html
<nav class="navigation"> <ul class="pagination"> <li class="Previous" v-on:click="first">首页</li> <li class="Previous" v-on:click="prev">上一页</li> <li> <a href="javascript:void(0);" class="nowStyle"> {{ page }}</a> </li> <li><input type="text" class="pageinput" ref="pageinput" @keyup.enter="press"></li> <li class="Next" v-on:click="next">下一页</li> <li class="Next" v-on:click="last">尾页</li> </ul></nav>
js
export default { data () { return { pages: [], page: 1, lists: [], pageinput: '' } }, created () { var that = this var params = {page: 1} that.$api.post('###', params, function (req) { that.pages = req.content.pages }) }, methods: { // 回车跳转 press () { var that = this that.pageinput = that.$refs.pageinput.value if (that.pageinput <= that.pages) { that.page = that.pageinput that.searchs() } }, // 首页 first () { var that = this that.page = that.page - that.page + 1 that.$refs.pageinput.value = '' that.searchs() }, // 尾页 last () { var that = this that.page = that.pages that.$refs.pageinput.value = '' that.searchs() }, // 上一页 prev () { var that = this that.page = that.page - 1 < 1 ? 1 : that.page - 1 that.$refs.pageinput.value = '' that.searchs() }, // 下一页 next () { var that = this that.page = parseInt(that.page) + 1 > that.pages ? that.pages : parseInt(that.page) + 1 that.$refs.pageinput.value = '' that.searchs() }, searchs () { var that = this var params = {page: that.page} that.$api.post('order/orderList', params, function (req) { that.lists = req.content.list that.pages = req.content.pages }) } }}
阅读全文
0 0
- vue 分页
- vue 分页
- Vue 分页
- 【VUE】vue分页插件share
- vue分页器
- Vue封装分页组件
- vue分页组件编写
- VUE+elementUI分页
- vue制作分页效果
- 使用vue制作分页
- VUE客户端分页
- Vue分页实例
- vue 简单分页组件
- vue分页组件table-pagebar
- Vue 分页组件 v2.0
- Vue实现web分页组件
- VUE分页组件table-pagebar
- Vue.js 实现分页查询
- Spring学习——关于Spring jpa data遇到的坑
- YTU OJ 2238: 括号匹配(栈和队列)
- Instruments 中 Leaks使用
- jQuery.inArray() 函数详解
- HttpClient中文
- vue 分页
- LinuxStudyNote(24)-Linux常用命令(4)-文件搜索命令(1)find文件搜索命令
- syn flood攻击防范
- 让iPhone自惭形秽?关于新品三星Galaxy S8\/S8+,最全汇总看这里!
- 新版 iPhone7 发布!最好别让女朋友看到,山寨机已经出现
- 【Codeforces176D】Hyper String
- 美国101岁亿万富豪洛克菲勒去世;乐视汽车宣布张海亮接任全球CEO;小米员工买房半价没产权…
- Frequent Subsets Problem(北京网赛)
- 课堂练习2