方法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="6aaW6aG1"
@click.prevent="gotoPage(1)">首</a>
<a
:class="{undisable: !teacherData.hasPrevious}"
href="#"
title="5YmN5LiA6aG1"
@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="J+esrA=="+page+'页'"
href="#"
@click.prevent="gotoPage(page)">{{ page }}</a>
<a
:class="{undisable: !teacherData.hasNext}"
href="#"
title="5ZCO5LiA6aG1"
@click.prevent="gotoPage(teacherData.current+1)">></a>
<a
:class="{undisable: !teacherData.hasNext}"
href="#"
title="5pyr6aG1"
@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实现输入提示效果 2023-02-14
- jsPlumb+vue创建字段映射关系 2023-10-08
- vue keep-alive 2023-10-08
- JS实现左侧菜单工具栏 2022-08-31
- layui数据表格以及传数据方式 2022-12-13
- 1 Vue - 简介 2023-10-08
- javascript 判断当前浏览器版本并判断ie版本 2023-08-08
- 深入浅析AjaxFileUpload实现单个文件的 Ajax 文件上传库 2022-12-15
- 基于CORS实现WebApi Ajax 跨域请求解决方法 2023-02-14
- 关于 html:如何从 css 表中删除边距和填充 2022-09-21