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作为参数传入后端,就可以完成分页了
相关推荐
linsa_pursuer1 天前
移动零算法
java·算法
lihao lihao1 天前
模板进阶
java·数据结构·算法
山风wind1 天前
Spring中责任链模式的工业级应用简单剖析
java·spring·责任链模式
星空寻流年1 天前
c3p0连接池isClosed()异常事故分析:MyBatis版本兼容问题排查与解决
mybatis
中年程序员一枚1 天前
Springboot使用maven编译报juh-3.2.1.jar缺失
spring boot·maven·jar
韩立学长1 天前
基于Springboot建筑物保护可视化系统rk6tni53(程序、源码、数据库、调试部署方案及开发环境)系统界面展示及获取方式置于文档末尾,可供参考。
数据库·spring boot·后端
Element_南笙1 天前
BUG:ModuleNotFoundError: No module named ‘milvus_lite‘
java·服务器·数据库
yyy(十一月限定版)1 天前
C++基础
java·开发语言·c++
Coder_Boy_1 天前
分布式系统设计经验总结:金融vs电商的核心差异与决策思路
java·运维·微服务·金融·电商
铅笔侠_小龙虾1 天前
Ubuntu 搭建前端环境&Vue实战
linux·前端·ubuntu·vue