方法1、//Java部分的主要实现的业务逻辑public MapString, Object getTeacherFrontList(PageEduTeacher pageTeacher) {QueryWrapperEduTeacher wrapper = new QueryWrapper();wrapper.orderByDesc(id);Pag...
方法1、
//Java部分的主要实现的业务逻辑
public Map<String, Object> getTeacherFrontList(Page<EduTeacher> pageTeacher) {
QueryWrapper<EduTeacher> wrapper = new QueryWrapper<>();
wrapper.orderByDesc("id");
Page<EduTeacher> teacherPage = baseMapper.selectPage(pageTeacher, wrapper);
List<EduTeacher> teacherRecords = teacherPage.getRecords();
long total = teacherPage.getTotal();
long current = teacherPage.getCurrent();
long pages = teacherPage.getPages();
boolean next = teacherPage.hasNext();
long size = teacherPage.getSize();
boolean previous = teacherPage.hasPrevious();
Map<String, Object> teacherMap = new HashMap<>();
teacherMap.put("items",teacherRecords);
teacherMap.put("total",total);
teacherMap.put("current",current);
teacherMap.put("size",size);
teacherMap.put("hasNext",next);
teacherMap.put("hasPrevious",previous);
teacherMap.put("pages",pages);
return teacherMap;
}
//JS部分的主要实现业务逻辑
<div>
<div class="paging">
<!-- undisable这个class是否存在,取决于数据属性hasPrevious -->
<a
:class="{undisable: !teacherData.hasPrevious}"
href="#"
title="首页"
@click.prevent="gotoPage(1)">首</a>
<a
:class="{undisable: !teacherData.hasPrevious}"
href="#"
title="前一页"
@click.prevent="gotoPage(teacherData.current-1)"><</a>
<a
v-for="page in teacherData.pages"
:key="page"
:class="{current: teacherData.current == page, undisable: teacherData.current == page}"
:title="'第'+page+'页'"
href="#"
@click.prevent="gotoPage(page)">{{ page }}</a>
<a
:class="{undisable: !teacherData.hasNext}"
href="#"
title="后一页"
@click.prevent="gotoPage(teacherData.current+1)">></a>
<a
:class="{undisable: !teacherData.hasNext}"
href="#"
title="末页"
@click.prevent="gotoPage(teacherData.pages)">末</a>
<div class="clear"/>
</div>
</div>
<script>
export default {
asyncData({ params, error }) {
return teacher.getTeacherList(1, 8).then(response => {
console.log("teacher数据",response.data.data);
return { teacherData: response.data.data }
});
},
methods:{
gotoPage(page){
teacher.getTeacherList(page, 8)
.then(response => {
this.teacherData = response.data.data
})
}
}
};
</script>
//请求的js部分
getTeacherList(current,limit) { //查询讲师列表
return request({
url: `/eduservice/teacherfront/getTeacherFrontList/${current}/${limit}`,
method: 'get'
})
},
沃梦达教程
本文标题为:vue+springboot实现分页
基础教程推荐
猜你喜欢
- Ajax发送和接收请求 2022-12-15
- uniapp开发微信小程序自定义顶部导航栏功能实例 2022-10-21
- 关于Ajax跨域问题及解决方案详析 2023-02-23
- 使用ajax跨域调用springboot框架的api传输文件 2023-02-23
- 在实战中可能碰到的几种ajax请求方法详解 2023-02-01
- cocos creator游戏实现loading加载页面,游戏启动加载动画 2022-10-29
- JS滚动到顶部踩坑解决记录 2023-07-10
- Ajax+smarty技术实现无刷新分页 2022-12-15
- HTML clearfix清除浮动讲解 2022-11-20
- Javascript Bootstrap的网格系统,导航栏和轮播详解 2023-08-11