方法一通过done回调进行遍历:
创新互联公司长期为1000多家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为东源企业提供专业的成都网站设计、网站建设,东源网站改版等技术服务。拥有十余年丰富建站经验和众多成功案例,为您定制开发。
//方法级渲染 table.render({ id: 'demoList', elem: '#demoList' , url: 'showDemoList' , cols: [[ {checkbox: true, fixed: true, width: '10%'} , {field: 'id', title: '编号', width: '15%', sort: true} , {field: 'pipe_id', title: '机构ID', width: '15%'} , {field: 'bank_id', title: '银行ID', width: '10%'} , {field: 'pipe_cost', title: '成本', width: '10%'} , {field: 'status', title: '状态', width: '20%'} , {field: 'remark', title: '操作', width: '20%', toolbar: '#toolBar'} ]], done: function (res, curr, count) { //如果是异步请求数据方式,res即为你接口返回的信息。 //如果是直接赋值的方式,res即为:{data: [], count: 99} data为当前页数据、count为数据总长度 $("[data-field='status']").children().each(function () { if ($(this).text() == '0') { $(this).text('有效'); } else if ($(this).text() == '1') { $(this).text('无效'); } }); } , page: true , height: 'full-83' });
方法二通过layui的templet模板实现:
, {field: 'status', title: '状态', width: '20%',templet:'#status'} <script type="text/html" id="status"> {{# if(d.status=='0'){ }} 有效 {{# }else{ }} 无效 {{# } }} </script>
以上这篇layui 对table中的数据进行转义的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持创新互联。
分享题目:layui对table中的数据进行转义的实例
网页链接:https://www.cdcxhl.com/article40/pjjdeo.html
成都网站建设公司_创新互联,为您提供移动网站建设、外贸建站、面包屑导航、搜索引擎优化、全网营销推广、小程序开发
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联