layui 数据表格 根据值(1=业务,2=机构)显示中文名称


数据是用ThinkPHP5操作

类型是固定4个,

 

用layui templet - 自定义模板 方法一:

 {field:'type', title: '类型', width: 200, templet: '#titleTpl'}

 

 <script type="text/html" id="titleTpl">
  if({{d.type}}=='2'){机构}else if({{d.type}}=='3'){财务}
</script> 
 
 
 
其它方法二:(ThinkPHP5读数据)
            //分类显示中文名称
            $("[data-field='type']").children().each(function(){
                    if($(this).text()=='1'){
                       $(this).text("教务")
                    }else if($(this).text()=='2'){
                       $(this).text("机构")
                    }else if($(this).text()=='3'){
                       $(this).text("财务")
                    }else if($(this).text()=='4'){
                       $(this).text("业务")
                    }
            })

 

 

转:https://blog.csdn.net/haibo0668/article/details/78193575

 

参考 :http://www.layui.com/demo/table/style.html

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM