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作为参数传入后端,就可以完成分页了
相关推荐
keyipatience31 分钟前
线程栈与TLS和线程互斥
java·linux·服务器·开发语言·ubuntu
weixin_408099671 小时前
2026 图片去水印 API 接口完全指南:一键去除图片水印(附 Python/Java/PHP/C# 示例)
java·python·php·图片处理·api调用·图片去水印·石榴智能
钱六两1 小时前
#3、SpringAI 接入deepSeek大模型(喂饭版)
java·spring boot·ai编程
Suhan422 小时前
IDEA 设置启动参数和环境变量
spring boot·spring·编辑器·idea
null_173 小时前
IntelliJ IDEA 极致流畅配置方案:Ultra 9 285K + 64GB 内存实测
java·ide·intellij-idea
Herbert_hwt3 小时前
建立Java程序开发
java·开发语言
好好沉淀3 小时前
@ExcelIgnoreUnannotated 和 @AutoMapper 详解
java
愚公移码3 小时前
蓝凌EKP18产品:流程虚拟机(PVM)
java·开发语言·前端
驰骋工作流3 小时前
流程引擎BPM设计之:流程消息
java·工作流引擎·bpm·jflow·ccflow
dogstarhuang3 小时前
从 0 到 1 搭建可收费的 API 开放平台(实战)
java·架构·api