TNBLOG
首页
博客
视频
资源
问答
猿趣
手机
关于
搜索
收藏
便签
笔记
消息
创作
登录
剑轩
故如虹,知恩;故如月,知明
博主信息
排名
6
文章
6
粉丝
16
评论
8
文章类别
CSS
15篇
微服务
41篇
Git
14篇
.NET
102篇
移动开发
33篇
软件架构
23篇
.NET Core
119篇
.NET MVC
11篇
英语
3篇
随笔
86篇
Bootstrap
3篇
Redis
21篇
编辑器
10篇
Js相关
15篇
虚拟化
8篇
更多
Oracle
7篇
Python
14篇
数据库
26篇
EF
17篇
微信
3篇
前端
151篇
消息队列
6篇
docker
41篇
多线程
1篇
Java
4篇
软件基础
2篇
C++
2篇
WCF
7篇
Linux
7篇
nginx
5篇
K8S
9篇
ABP
2篇
最新文章
最新评价
{{item.articleTitle}}
{{item.blogName}}
:
{{item.content}}
关于我们
ICP备案 :
渝ICP备18016597号-1
网站信息:
2018-2024
TNBLOG.NET
技术交流:
群号656732739
联系我们:
contact@tnblog.net
欢迎加群
欢迎加群交流技术
原
vue elementui分页条使用与.net后台sqlsugar等分页方法使用。常用分页模板
1358
人阅读
2019/6/29 18:28
总访问:
3913860
评论:
0
收藏:
0
手机
分类:
.NET
#### 分页条 ``` <div style="margin-top: 20px;margin-bottom: 20px;text-align: center;"> <el-pagination :total="totalCount" :page-size="10" background layout="prev, pager, next" @current-change="handleCurrentChange"/> </div> ``` page-size写死的,完全可以写成变量 ### 绑定的页数的变量 ``` data() { return { feedbackList: [], totalCount: 0 } } ``` #### 处理分页的方法与查询数据的方法 ``` methods: { changeDateFormat(jsondate) { var date = new Date(jsondate).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '') return date }, // 处理分页的事件 handleCurrentChange(val) { this.saveFeedback(val) }, // 获取反馈 分页查询 saveFeedback(PageIndex) { const loading = this.$loading({ lock: true, text: 'Loading', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }) const _this = this this.$http.get('/education/api/Feedback/GetFeedbackListByStudent', { PageIndex: PageIndex, PageSize: 10 }).then(res => { _this.feedbackList = res.data.data _this.totalCount = res.data.dataCount loading.close() }).catch(e => { loading.close() } ) } } ``` 同样page-size写死的,完全可以写成变量 #### 后台接口方法 **接口入口** ``` [HttpGet] public ObjectResult GetFeedbackListByStudent([FromQuery] GetFeedbackDto input) { //input.PageIndex = 1; //input.PageSize = 20; input.StudentID = currentUser.AccountID; //input.StudentUserName = currentUser.GetAccountInfo().UserName; PageData<Feedback> feedbacks = feedbackService.GetFeedbackListByStudent(input); return Success(feedbacks); } ``` **分页与数据查询方法** ``` public PageData<Feedback> GetFeedbackListByStudent(GetFeedbackDto input) { int dataCount = 0; List<Feedback> feedbacks = Db.Queryable<Feedback>() .Where(a => a.StudentID == input.StudentID) .OrderBy(a => a.CreateTime, OrderByType.Desc).ToPageList(input.PageIndex, input.PageSize, ref dataCount); var pagination = new PageData<Feedback>(); pagination.PageIndex = input.PageIndex; pagination.PageSize = input.PageSize; pagination.DataCount = dataCount; pagination.Data = feedbacks; return pagination; //return feedbacks; } ``` **返回的实体** ``` public class PageData<T> where T : class, new() { // // 摘要: // 当前页数 public int PageIndex { get; set; } // // 摘要: // 每页数据条数 public int PageSize { get; set; } // // 摘要: // 数据总条数 public int DataCount { get; set; } // // 摘要: // 数据列表 public IList<T> Data { get; set; } } ``` **分页条件的base实体** ``` public class QueryConditionBase { public string? Key { get; set; } = ""; public int PageIndex { get; set; } public int PageSize { get; set; } } ``` 有其他条件就写个实体,继承它
欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739
👈{{preArticle.title}}
👉{{nextArticle.title}}
评价
{{titleitem}}
{{titleitem}}
{{item.content}}
{{titleitem}}
{{titleitem}}
{{item.content}}