beego分页类
count, _ := models.M("logoperation").Alias(`op`).Field(`count(op.id) as count`).Where(where).Count() if count > 0 { pagesize := 10 p := tools.NewPaginator(this.Ctx.Request, pagesize, count) log, _ := models.M("logoperation").Alias(`op`).Where(where).Limit(strconv.Itoa(p.Offset()), strconv.Itoa(pagesize)).Order(`op.id desc`).Select() this.Data["data"] = log this.Data["paginator"] = p }
模板
<div style="text-align:center;padding-left: 100px;margin-top: -24px;float: right;" class="pagination"> {{if .paginator}} {{if gt .paginator.PageNums 1}} <ul class="pagination pagination-sm"> {{if .paginator.HasPrev}} <li> <a href="{{.paginator.PageLinkFirst}}">首页</a> </li> <li> <a href="{{.paginator.PageLinkPrev}}">上一页</a> </li> {{else}} <li class="disabled"> <a>首页</a> </li> <li class="disabled"> <a>上一页</a> </li> {{end}} {{range $index, $page := .paginator.Pages}} <li{{if $.paginator.IsActive .}} class="active"{{end}}> <a href="{{$.paginator.PageLink $page}}">{{$page}}</a> </li> {{end}} {{if .paginator.HasNext}} <li> <a href="{{.paginator.PageLinkNext}}">下一页</a> </li> <li> <a href="{{.paginator.PageLinkLast}}">末页</a> </li> {{else}} <li class="disabled"> <a>下一页</a> </li> <li class="disabled"> <a>末页</a> </li> {{end}} <li class="disabled"> <a> 共{{.paginator.Nums }}条数据 每页{{.paginator.PerPageNums}}条 当前{{.paginator.Page}}/{{.paginator.PageNums}}页 </a> </li> <li> <input type="text" id="tiaozhuan" placeholder="跳转页" style="width: 47px;height: 30px;border: 1px solid #dddddd;border-left: 0px;border-radius: 0px 4px 4px 0px;text-align: center;"></li> </ul> {{end}} {{end}} </div>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。