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作为参数传入后端,就可以完成分页了
相关推荐
千寻技术帮1 分钟前
10343_基于Springboot的考研信息查询系统
mysql·vue·springboot·考研论坛·考研录取
yangminlei2 分钟前
Spring Boot 实现 DOCX 转 PDF
开发语言·spring boot·python
悟道|养家2 分钟前
基于L1/L2 缓存访问速度的角度思考数组和链表的数据结构设计以及工程实践方案选择(2)
java·开发语言·缓存
虫小宝4 分钟前
微信群发消息API接口对接中Java后端的请求参数校验与异常反馈优化技巧
android·java·开发语言
麦兜*6 分钟前
Spring Boot整合Swagger 3.0:自动生成API文档并在线调试
java·spring boot·后端
星火开发设计12 分钟前
C++ deque 全面解析与实战指南
java·开发语言·数据结构·c++·学习·知识
独自破碎E12 分钟前
什么是RabbitMQ中的死信队列?
java·rabbitmq·java-rabbitmq
码界奇点13 分钟前
基于Spring与Netty的分布式配置管理系统设计与实现
java·分布式·spring·毕业设计·源代码管理
计算机毕设指导614 分钟前
基于微信小程序的咖啡店点餐系统【源码文末联系】
java·spring boot·微信小程序·小程序·tomcat·maven·intellij-idea
Geoking.14 分钟前
【设计模式】外观模式(Facade)详解
java·设计模式·外观模式