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) ;
         }
     });

}
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐