首页 > 其他分享 >使用element-plus组件在vue中引入分页功能

使用element-plus组件在vue中引入分页功能

时间:2023-09-12 21:34:58浏览次数:42  
标签:vue springframework element plus org import annotation page size

1、组件的引入

<el-pagination background layout="prev, pager, next"
                     page-size="6"
                     :total="60" >
      </el-pagination>

2、存在问题就是,现在页码并不能与每页的内容相互对应

解决方式:


page用来表示确认每一页是否点击到,正式版本会删除;

点击即有显示:

2、更改后端形式

controller:

package com.example.myspring001.controller;

import com.example.myspring001.entity.Student;
import com.example.myspring001.repository.StudentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private StudentRepository studentRepository;

    @GetMapping("/findAll/{page}/{size}")
    public Page<Student> findAll(@PathVariable("page") Integer page, @PathVariable("size") Integer size){
        Pageable pageable= PageRequest.of(page-1,size);
        return studentRepository.findAll(pageable);
    }
}

page--第几页;

size--每页的数量;

后台实现分页查询:

标签:vue,springframework,element,plus,org,import,annotation,page,size
From: https://www.cnblogs.com/liuzijin/p/17697820.html

相关文章

  • OpenTiny Vue组件库实现跨框架(vue2、vue3、react、solid)
    本文由TinyVue组件库核心成员郑志超分享,首先分享了实现跨框架组件库的必要性,同时通过演示demo和实际操作向我们介绍了如何实现一个跨框架的组件库。前言前端组件库跨框架是什么?前端组件库跨框架是指在不同的前端框架(如React、Vue、Solid等)之间共享和复用组件的能力。这种能力可以让......
  • vue3.*安装axios具体步骤
    在项目的命令行处使用命令进行axios的安装npminstallaxiosvue-axios--legacy-peer-deps--save其余的命令可能会报错;......
  • 基于vue制作的动画组件loading起来
    ......
  • vue实现动态导航栏的设置
    1、点击某个导航栏即切换到某个页面1、为el-menu标签加上router属性2、在页面中添加router-view标签,动态渲染我们自己选择的router3、el-menu-item标签的index值即为要跳转的页面地址呈现效果:2、为页面设置选中状态--此时点击选中是有状态的,但是初始化的时候,就不会有什......
  • 实现类似elementui中的树节点过滤效果
    filterTree(tree,arr=[]){letthat=thisif(!tree.length)return[];for(letitemoftree){letnode={}if(item.name.indexOf(this.searchVal)>-1){constitemValue={...item};node={......
  • 一图看懂iPhone 15系列:15/Plus/Pro/Pro Max有啥区别?详细配置对比
    距离iPhone15系列发布只剩下2天(北京时间9月13日凌晨1点),即将推出预计分别是iPhone15、iPhone15Plus,以及Pro系列的iPhone15Pro以及iPhone15ProMax。TrendForce集邦汇总了四款新机规格预测。硬件方面,受欧盟订定法案的限制,苹果也将于今年加入Type-C的行列,全新更换C口。iPho......
  • vue 嵌套全屏iframe 能有效避开返回两次才能返回上一个路由的问题
    <template> <divclass="home">  <iframeref="iframe"class="iframe"frameborder="no"></iframe> </div></template><script>import{ get_doctor_info, statistics, ......
  • element ui 如何在一行放置三个输入框和两个按钮
    代码示例:<el-form:model="form":rules="rules"label-width="80px"inline><el-row><el-col:span="6"><el-form-itemlabel="First"wordprop="first"><......
  • vue 学习
    1.给对象动态添加属性和值varobj={   name:"jack",   age:"18"}第一种:Vue.set(obj,'sex','18');第二种:this.$set(this.obj,'score',90);第三种:obj.score=100;直接赋值的方式不能触发Vue的响应式系统。如果我们需要在模板中使用动态添加的属性,建议使用Vue.set......
  • Vue3中使用pinia全局状态管理库
    ❝本期介绍一下pinia在vue3中的简单使用,以及如何使用pinia实现多页面状态共享。❞什么是piniaPinia是一个用于Vue应用程序的轻量级状态管理库。与vuex的区别pinia是vue3的官方状态管理库,vuex是vue2的官方状态管理库pinia更加轻量级pinia能更好的配合Vue3与TSpinia的使用比Vuex简......