关于分页插件的使用
一、项目背景
需用用到分页进行大量数据的管理。 使用 jquery.js 和 分页插件 pagination.js 插件地址:
https://github.com/Maxiaoxiang/jQuery-plugins
二、效果
二、使用
需先引入jQuery,再引入pagination组件 html
<div class="M-box3"></div>
css 样式可自行修改
@charset "UTF-8";
.m-style {
position: relative;
text-align: center;
zoom: 1;
}
.m-style:before,
.m-style:after {
content: "";
display: table;
}
.m-style:after {
clear: both;
overflow: hidden;
}
.m-style span {
float: left;
margin: 0 5px;
width: 38px;
height: 38px;
line-height: 38px;
color: #bdbdbd;
font-size: 14px;
}
.m-style .active {
float: left;
margin: 0 5px;
width: 38px;
height: 38px;
line-height: 38px;
background: #e91e63;
color: #fff;
font-size: 14px;
border: 1px solid #e91e63;
}
.m-style a {
float: left;
margin: 0 5px;
width: 38px;
height: 38px;
line-height: 38px;
background: #fff;
border: 1px solid #ebebeb;
color: #bdbdbd;
font-size: 14px;
}
.m-style a:hover {
color: #fff;
background: #e91e63;
}
.m-style .next,
.m-style .prev {
font-family: "Simsun";
font-size: 16px;
font-weight: bold;
}
.now,
.count {
padding: 0 5px;
color: #f00;
}
.eg img {
max-width: 800px;
min-height: 500px;
}
input {
float: left;
margin: 0 5px;
width: 38px;
height: 38px;
line-height: 38px;
text-align: center;
background: #fff;
border: 1px solid #ebebeb;
outline: none;
color: #bdbdbd;
font-size: 14px;
}
javascript
$(function () {
Render()
})
function Render() {
getData()
.then(function (res) {
var num = res.totalpage
console.log(num);
$('.M-box3').pagination({
pageCount: num,
jump: true,
coping: true,
homePage: '首页',
endPage: '末页',
prevContent: '上页',
nextContent: '下页',
callback: function (api) {
var page = api.getCurrent())
getData({page:page})
.then(function (res){
$('xxx').append(`xxxxxxxxxxx`)
})
},
});
})
}
function getData(params) {
return new Promise(function (resolve, reject) {
$.ajax({
url: 'https://*************',
data:params
success: function (res) {
resolve(res.data)
},
error: function (err) {
reject(err)
}
})
})
}
|