1 回答

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超3個(gè)贊
修改如下:
1.丟了curr參數(shù)。
2.跳頁(yè)laypage自帶參數(shù)jump
3.數(shù)據(jù)會(huì)累加是因?yàn)橹匦虏樵冎皼](méi)有清空數(shù)據(jù)。
//查詢?nèi)啃畔?/p>
function getInfo(page) {
$.ajax({
type: 'post',
url: '/web/illegalMessages',
//dataType:'json',
data: {
'page': page
},
async: false,
success: function(data) {
//var data = JSON.parse(data);
var list = data.data;
totalRow = data.totalRow; //獲取總條數(shù)
if (data.flag == 'success') {
$('tbody').html(''); //先清空,否則再次查詢會(huì)在本頁(yè)累加數(shù)據(jù)
for (var i = 0; i < list.length; i++) {
$('tbody').append(
'<tr id="' + list[i].illegalmessageid + '">' +
'<td>' + list[i].deal + '</td>' +
'<td>' + list[i].occurarea + '</td>' +
'<td>' + list[i].platenumber + '</td>' +
'<td>' + list[i].occurtime + '</td>' +
'<td>' + list[i].markImgPath + '</td>' +
'<td>' + list[i].detailImgPath + '</td>' +
'<td>' + list[i].voicePath + list[i].videoPath + '</td>' +
'<td>' + list[i].deal + '</td>' +
'</tr>'
)
}
}
//配置并加載所需模塊
layui.config({
base: 'base/lay/modules/'
}).use(['laypage', 'table'], function() {
var laypage = layui.laypage;
var table = layui.table;
//實(shí)例化分頁(yè)
laypage.render({
elem: 'layPage' //分頁(yè)容器的id
,
layout: ['prev', 'page', 'next', 'limits', 'count'] //排版
,
limit: 10 //每頁(yè)顯示數(shù)
,
count: totalRow //總條數(shù)
,
curr: page
,
groups: 3 //連續(xù)出現(xiàn)的頁(yè)數(shù)
,
theme: '#1E9FFF' //自定義選中色值
,
skip: true //開(kāi)啟跳頁(yè)
,
jump: function(obj, first) { //點(diǎn)擊頁(yè)碼跳頁(yè)
if (!first) {
$('tbody').html('');
getInfo(obj.curr); //查詢,傳參:當(dāng)前頁(yè)
}
}
});
});
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
console.log(XMLHttpRequest.status);
console.log(XMLHttpRequest.readyState);
console.log(textStatus);
},
})
}
$(function() {
//初始化加載所有信息
getInfo(1);
})
添加回答
舉報(bào)