时间:2021-05-26
html代码:
<section class="container page-home"><div id="main-content" class="wrap-container zerogrid"><article id="news_content" v-for="item in items"><div class="col-1-2 right"><img :src="item.coverimage" class="news_image"/><!-- :要与img标签之间有空格 --></div><div class="col-1-2 left"><a class="art-category left" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >{{item.releasetime.substring(0,19)}}</a><div class="clear"></div><div class="art-content"><h2>{{item.title}}</h2><div class="info"><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >{{item.author}}</a></div><div class="line"></div><p>{{item.remark}}</p><a v-bind:href="['/island/stage/newscontent.html?id='+item.id+'&categoryid='+item.categoryid]" rel="external nofollow" class="more">阅读全文</a><span href="javascript:;" rel="external nofollow" class="more" style="margin-left:50px;">浏览量 : {{item.reading}}</span></div></div></article><!-- 循环结束(新闻) --></div><div id="pagination" class="clearfix"><ul><li v-for="page in pages"><a class="current" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" v-if="currentPage == page">{{page}}</a><!-- 高亮显示当前页 --><a class="choose_page" v-if="currentPage != page" @click="clickpage">{{page}}</a></li><li v-if="pages > 1"><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >next</a></li></ul></div></section>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 vuejava后台:
package com.zrq.util;import java.util.List;import org.springframework.stereotype.Component;@Componentpublic class PageUtil {/** // 默认的每页记录数量(10条) private static final int DEFAULT_PAGE_SIZE = 10; /// 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();elsetotalPage = totalCount / this.getEveryPage() + 1;return totalPage;}public void hasPrevious() {if (currentPage > 1)this.setPrevious(true);elsethis.setPrevious(false);}public void hasNext() {if (currentPage < this.getTotalCount())this.setNext(true);elsethis.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分页中单击页码更换页面内容的方法(配合spring springmvc)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文实例为大家分享了Vue.js实现分页查询的具体代码,供大家参考,具体内容如下vue.js的使用如下:1、引入vue.jsa、分页条b、分页条js、css2、
前言为了练习vue.js之前做了一个vue.js前端分页效果,后面看到vue.js组件内容,就试着把这个功能写成一个简单组件,向组件元素传递一个object参数
利用vue.js实现数据库分页,供大家参考,具体内容如下最新项目有一个分页功能,画面风格很简朴给的样图就用【1】表示页码了,因此,我没有上网上找插件,自己简单的
介绍vue-router是Vue.js官方的路由插件,它和vue.js是深度集成的,适合用于构建单页面应用。vue的单页面应用是基于路由和组件的,路由用于设定访
vue-router是Vue.js官方的路由插件,它和vue.js是深度集成的,适合用于构建单页面应用。vue的单页面应用是基于路由和组件的,路由用于设定访问路