layui table指定某一行样式

想指定layui table中某一行的样式,找了这个资源可行。转自: https://blog.csdn.net/weixin_44729896/article/details/100524824

table.render({
          elem: "#test",
          // id: "table_cell_data",
          url: "http://localhost:3000/all",
          toolbar: "#toolbarDemo", //指向自定义工具栏模板选择器
          defaultToolbar: [], //除去打印,导出
          title: "用户数据表",
          cols: [[ ]],
          page: false,
          done: function (res, curr, count) {
            console.log(res.data);
            merge(res);
            var that = this.elem.next();
            console.log(this.elem)
            console.log(that)
            res.data.forEach(function (item, index) {
                if (item.accstatus === "封禁") {
                  var tr = that.find(".layui-table-box tbody tr[data-index='" + index + "']");
                  tr.css("background-color", "yellow");
                  tr.find(".laytable-cell-1-0-9").css("color","red");

                } 
            });
          }
        });

效果如下图:

猜你喜欢

转载自www.cnblogs.com/newcapecjmc/p/11797714.html