layui 中的 table 组件有回调方法,需要在回调方法里面添加。
done: function (res, curr, count) {
/*
res : table 中的数据
*/
// 设置背景颜色
let backgroundColor = "#DAA520" ;
// 循环 table 中的数据
res.data.forEach(function(item,index,self){
// 判断想要改变的条件
if (item.zt == '2'){
// 给 表格设置背景色
$('.layui-table').find('tr[data-index ='+index+']').css("background-color",backgroundColor) ;
}
});
}