網站首頁 編程語言 正文
分頁組件是比較常用的,有表格的地方基本上都存在分頁,使用 elementui 里面的分頁進行封裝方便使用。
一. 后端分頁
<template>
<div class="pagination">
<el-pagination @size-change="sizeChange"
@current-change="currentChange"
:current-page="currentPage"
:page-sizes="propPageSizes"
:page-size="pageSize"
background
layout="total, sizes, prev, pager, next, jumper"
:total="total"
v-if="total > 0">
</el-pagination>
</div>
</template>
<script>
export default {
props: {
callback: { // 獲取列表數據方法
type: Function,
default() {
return function() {};
}
},
propCurrentPage: { // 當前頁
type: [Number],
default: 1
},
propPageSizes: { // 配置每頁顯示多少條
type: Array,
default: function() {
return [10, 20, 30];
}
},
propPageSize: { // 默認每頁顯示條數
type: [Number],
default: 10
},
total: { // 數據總條數
type: [Number],
default: 0
}
},
data() {
return {
currentPage: this.propCurrentPage, // 頁面的當前頁
pageSize: this.propPageSize // 頁面分頁器大小
};
},
methods: {
// 改變當前頁
currentChange(val) {
this.currentPage = val;
this['callback']();
},
// 改變每頁顯示多少條
sizeChange(val) {
this.pageSize = val;
this.currentPage = 1;
this['callback']();
}
}
};
</script>
<style lang="less" scoped>
// 樣式根據自己的實際情況修改,也可以用下邊的
.pagination {
margin-top: 20px;
text-align: right;
/deep/ .el-pagination.is-background .el-pager li,
/deep/ .el-pagination.is-background .btn-prev,
/deep/ .el-pagination.is-background .btn-next {
color: #666;
background-color: #fff;
border: 1px solid #e4e9ec;
border-radius: 4px;
}
/deep/ .el-pagination.is-background .el-pager li:not(.disabled).active {
color: #11889c;
background-color: #fff;
border: 1px solid #11889c;
}
/deep/ .el-pagination.is-background .btn-prev:disabled,
/deep/ .el-pagination.is-background .btn-next:disabled {
color: #c0c4cc;
}
}
</style>
<Pagination
ref="pagination"
:callback="getMsgList"
:total="total">
</Pagination>
效果圖
二. 前端實現分頁
待更新。。。
這個分頁其實也沒什么難度,是后端實現的分頁,后面再總結下前端實現分頁的方法。有問題,歡迎大家隨時留言交流!
原文鏈接:https://blog.csdn.net/weixin_44980732/article/details/115900338
相關推薦
- 2022-06-01 python畫立方體--魔方_python
- 2022-11-26 詳解redis-cli?命令_Redis
- 2022-05-18 Python學習之自定義異常詳解_python
- 2022-08-04 Go?slice切片make生成append追加copy復制示例_Golang
- 2022-07-22 EasyExcel導出Excel 通過 RGB 設置 表頭顏色
- 2022-09-05 C語言之關于二維數組在函數中的調用問題_C 語言
- 2022-05-29 C#實現文本轉語音功能_C#教程
- 2023-01-26 Python中的lambda和apply用法及說明_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支