太阳集团tyc5997|官网【中国】有限公司

前后端结合实现amazeUI分页效果
  • 作者:admin
  • 发表时间:2021-01-20 07:56
  • 来源:未知

这篇文章主要介绍了前后端结合实现amazeUI分页,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

前后端结合实现amazeUI分页,代码如下所示;

借鉴

本文在博客https://blog.csdn.net/brave_coder/article/details/52367124的基础上实现的,非常感谢大佬的分享。

前端实现

1、引入paginator.js

(函数($) {

$ .fn。paginator=function(选项){

//这个指向当前的选择器

var config={

url: ' ',

pageParent: ' ',

total bar :-1,

limit: -1,

offset: 1,

callback: null

}

//合并参数

var opts=$ .扩展(配置,选项);

opts。总计栏=数学。ceil(opts。总计bar/opts。极限);

//计算按钮的总个数

//获取抵消参数

var queryString=function (url) {

var offset=(url.split('?')[1]).split('=')[1];

返回parseInt(偏移量);

}

//ajax核心方法,用于分页的数据操作

var ajaxCore=function (offset,fn) {

$.ajax({

url': opts.url,

数据' : {

偏移量' :偏移量,

limit': opts.limit

},

数据类型: 'JSON ',

方法' : '开机自检,

成功: fn

});

}

//重新装配分页按钮

var pageCore=函数(偏移量){

if (opts.offset==offset) {

返回;

} //如果是当前页面,那么就什么事都不用干了!

else {

ajaxCore(偏移量,opts。回调);

$(opts.pageParent).empty();

//否则,清空所有的节点,重新向数字正射影像图插入新的分页按钮

var输出=

var next bar=offset==opts。酒吧总数?Li class=\ ' am-disabled ' a yxref=\ ' JavaScript :\ '/a/Li ' : ' lia yxhref=\ ' \ '选择。URL(偏移量1)\ ' \ '/a/Li ';

var preBar=offset==1?Li class=\ ' am-disabled ' a yxref=\ ' JavaScript :\ '/a/Li ' : ' lia yxhref=\ ' \ '选择。URL(偏移量-1)' \ '/a/Li ';

//组装向上一个节点和下一页节点

if (opts.totalBars 7) {

if(偏移量5) {

output=preBar

for(var I=1;I=5;i ) {

if (i==offset) {

output=' Li class=\ ' am-active ' a yhref=\ '选项。URL偏移量“\”偏移量“/a/Li”;

} else {

output=' lia yx href=\ ' '选项。URL I ' \ ' ' I

}

}

output='lispan./span/Li ';

output=' lia yx href=\ ' '选项。URL(opts。total bar)' \ '(opts。total bar)'/a/Li ' next bar;

Baidu
sogou