1.常用操作模板
<script type="text/html" id="userbar"> <a class="layui-btn layui-btn-xs" lay-event="detail">查看</a> <a class="layui-btn layui-btn-xs" lay-event="change">修改</a> {{# var statusBut= function(date){ if(date==0){ return ‘<a class="layui-btn layui-btn-xs" lay-event="edit">配置</a>‘; }else if(date==1){ return‘<a class="layui-btn layui-btn-xs" lay-event="edit">禁用</a>‘; }else if(date==2){ return ‘<a class="layui-btn layui-btn-xs" lay-event="edit">启动</a>‘; } } }} {{ statusBut(d.status)}} <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a> </script>
2.时间格式转换模板
<script type="text/html" id="TimeTpl"> {{# var parseDate= function(date){ if(date){ var t=new Date(date); return t.getFullYear()+"-"+(t.getMonth()+1)+"-"+t.getDate()+" "+t.getHours()+":"+t.getMinutes(); } } }} {{parseDate(d.updateTime)}} </script>
3.状态转换模板
<script type="text/html" id="statusTpl"> {{# var statusTxt= function(date){ if(date==0){ return "未配置"; }else if(date==1){ return "启动"; }else if(date==2){ return "禁用"; } } }} {{ statusTxt(d.status)}} </script>