layui数据表格循环数据给特殊行变颜色遇到的bug
生活随笔
收集整理的這篇文章主要介紹了
layui数据表格循环数据给特殊行变颜色遇到的bug
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
數(shù)據(jù)表格加載玩數(shù)據(jù)后,進(jìn)行顏色區(qū)分,然后再進(jìn)行排序,發(fā)現(xiàn)顏色變化有bug
原因:
//其中res.data數(shù)據(jù)并沒有變化,只是渲染數(shù)據(jù)順序發(fā)生了變化,這時(shí)候,如此循環(huán)便會(huì)出現(xiàn)問題 $.each(res.data, function (i, val) {if (familyInfo.intervieweeCode != null) {if (res.data[i].memberCode == familyInfo.intervieweeCode) {$('.layui-table-main tr[data-index = ' + i + ']').css({ 'background-color': '#FF3030','color':'#fff' });$(".data-add-btn").css({ 'background-color': '#FF3030' });}} else if(str != null){if (res.data[i].memberCode == str) {$('.layui-table-main tr[data-index = ' + i + ']').css({ 'background-color': '#FF3030' });$(".data-add-btn").css({ 'background-color': '#FF3030' });}}});解決方案:
//重新獲取表格數(shù)據(jù),進(jìn)行渲染 let bData = layui.table.cache["currentTableId"];$.each(bData, function (i, val) { });總結(jié)
以上是生活随笔為你收集整理的layui数据表格循环数据给特殊行变颜色遇到的bug的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 大学生信用卡有哪些 这些卡适合你申请
- 下一篇: layui 数据表格 日期格式化