前后端开发之分页操作

分页操作的做法有很多种,可以通过前端分页,也可以通过后端分页。在此本人在后端分页(基于spring boot+vue

后端

  • 在pom.xml中添加依赖
<dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.2.5</version>
        </dependency>
  • 在application.properties中添加配置
pagehelper.helperDialect=mysql
pagehelper.reasonable=false
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql
  • 在Controller层中使用
    @GetMapping(value = "/*")
    public ResponseResult getAll(@RequestParam(defaultValue = "1") int pageNo, @RequestParam(defaultValue = "10") int pageSize) {
        PageHelper.startPage(pageNo,pageSize);
        //pageNo是页数,默认为1;pageSize是数量,默认为10
        //方法自写
        return ;
    }

前端

本人使用的是基于uni-app的开发

<template>
<uni-load-more :loadingType="loadingType" :contentText="contentText"></uni-load-more>
</template>
<script>
import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue"
export default {
    components: {uniLoadMore}
}
</script>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容