vue.js分页中如何实现单击页码更换页面内容
这篇文章主要为大家展示了“vue.js分页中如何实现单击页码更换页面内容”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“vue.js分页中如何实现单击页码更换页面内容”这篇文章吧。
10多年的巴林左旗网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。全网整合营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整巴林左旗建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。成都创新互联公司从事“巴林左旗网站设计”,“巴林左旗网站推广”以来,每个客户项目都认真落实执行。
html代码:
js:
/查询相关新闻种类下的所有新闻记录 var vm = new Vue({ el: '.page-home', //需要注入的模板的父元素 data: { items : [], pages : [], currentPage : [] }, //end data created:function(){ $.post("/island/stage/queryOneCategoryAllNews.do",{"categoryid":parseInt(categoryid),"currentPage":1},function(data){ vm.pages = data.totalPage; //总页码 vm.items = data.list; //循环内容 vm.currentPage = data.currentPage; //当前页(添加高亮样式) }); //end post }, //created methods:{ clickpage:function(event){ var currentPage = $(event.currentTarget).text(); $.post("/island/stage/queryOneCategoryAllNews.do",{"categoryid":parseInt(categoryid),"currentPage":parseInt(currentPage)},function(data){ vm.items = data.list; //循环内容 vm.pages = data.totalPage; //总页码 vm.currentPage = data.currentPage; //当前页(添加高亮样式) }); //end post } //end method } }); //end vue
java后台:
package com.zrq.util; import java.util.List; import org.springframework.stereotype.Component; @Component public class PageUtil { /* * // 默认的每页记录数量(10条) private static final int DEFAULT_PAGE_SIZE = 10; // * 默认当前页 private static final int DEFAULT_CURRENT_PAGE = 1; */ // 1.每页显示数量(everyPage) private int everyPage; // 2.总记录数(totalCount) private long totalCount; // 3.总页数 private long totalPage; // 4.当前页(currentPage) private int currentPage; // 5.起始下标(beginIndex) private int beginIndex; // 6.判断是否有上一页 private boolean next; // 7.判断是否有下一页 private boolean previous; // 8.返回列表 private List list; /* 获取总页数 */ public long getTotalPage() { long remainder = totalCount % this.getEveryPage(); // 剩余数 if (remainder == 0) totalPage = totalCount / this.getEveryPage(); else totalPage = totalCount / this.getEveryPage() + 1; return totalPage; } /* 判断是否有上一页 */ public void hasPrevious() { if (currentPage > 1) this.setPrevious(true); else this.setPrevious(false); } /* 判断是否有下一页 */ public void hasNext() { if (currentPage < this.getTotalCount()) this.setNext(true); else this.setNext(false); } public boolean isNext() { return next; } public boolean isPrevious() { return previous; } public void setTotalPage(long totalPage) { this.totalPage = totalPage; } public void setNext(boolean next) { this.next = next; } public void setPrevious(boolean previous) { this.previous = previous; } public int getEveryPage() { return everyPage; } public long getTotalCount() { return totalCount; } public int getCurrentPage() { return currentPage; } public int getBeginIndex() { return beginIndex; } public List getList() { return list; } public void setEveryPage(int everyPage) { this.everyPage = everyPage; } public void setTotalCount(long totalCount) { this.totalCount = totalCount; } public void setCurrentPage(int currentPage) { this.currentPage = currentPage; } public void setBeginIndex(int beginIndex) { this.beginIndex = beginIndex; } public void setList(List list) { this.list = list; } public PageUtil(int currentPage, int pageSize) { this.currentPage = currentPage; this.everyPage = pageSize; } public PageUtil() { /* * this.currentPage = DEFAULT_CURRENT_PAGE; this.everyPage = * DEFAULT_PAGE_SIZE; */ } public PageUtil(int everyPage, int totalCount, int currentPage, int beginIndex, List list) { super(); this.everyPage = everyPage; this.totalCount = totalCount; this.currentPage = currentPage; this.beginIndex = beginIndex; this.list = list; } }
以上是“vue.js分页中如何实现单击页码更换页面内容”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!
网站题目:vue.js分页中如何实现单击页码更换页面内容
文章网址:http://ybzwz.com/article/ghdjhh.html