springboot+mybatis+vue2分页功能开发

前端框架代码

 <div class="block">
    <span class="demonstration">完整功能</span>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage4"
      :page-sizes="[100, 200, 300, 400]"
      :page-size="100"
      layout="total, sizes, prev, pager, next, jumper"
      :total="400">
    </el-pagination>
  </div>

data中进行数据初始化

javascript 复制代码
data() {
    return {    
      totals: 0,
      pageSize: 2,
      currentPage: 1
}
}

对应的js代码

javascript 复制代码
 methods: {
    getParent() {
      getPatientList(this.currentPage, this.pageSize).then(res => {
        this.tableData = res.data.list
        this.totals = res.data.total
      })
    },
    handleSizeChange(val) {
      this.pageSize = val
      this.getParent()
      console.log(`每页 ${val} 条`)
    },
    handleCurrentChange(val) {
      this.currentPage = val
      this.getParent()
      console.log(`当前页: ${val}`)
    }
}

后端开发方法

这里使用的是mybatis,所有需要使用pagehelper进行分页

javascript 复制代码
 <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.4.7</version>
        </dependency>

后端使用

复制代码
PageInfo,并将pageNO和pageSize作为参数传入后端,就可以完成分页了
相关推荐
m0_7482478011 分钟前
SOA(面向服务架构)全面解析
java·微服务·架构
m0_7401546715 分钟前
Tomcat
java·tomcat
m0_7482338815 分钟前
Spring Boot 集成 MyBatis 全面讲解
spring boot·后端·mybatis
爱敲代码的小冰22 分钟前
【Excel】 Power Query抓取多页数据导入到Excel
android·java·excel
心流时间36 分钟前
[Java基础] JVM常量池介绍(BeanUtils.copyProperties(source, target)中的属性值引用的是同一个对象吗)
java·开发语言·jvm
快乐非自愿1 小时前
Spring Boot集成Spring Security之HTTP请求授权
spring boot·spring·http
瑞金彭于晏1 小时前
通俗易懂版 Maven 科普,maven是什么?
java·maven
好看资源平台1 小时前
Java Web开发实战与项目——Spring Boot与Spring Cloud微服务项目实战
java
不懂901 小时前
Spring Boot集成Jetty、Tomcat或Undertow及支持HTTP/2协议
spring boot·后端·http·https
.猫的树1 小时前
Java集合List快速实现重复判断的10种方法深度解析
java·开发语言·list·集合