layui tpl中的if(){}else{}的表达方式

∫`不撒娇的折耳猫 2020-5-26 2209

if-elseif-else:

{{# if (d.is_del=== 0) { }}
     <span>男</span>
{{# } else if(d.is_del=== 1) { }}
    <span>女</span>
{{# } else { }}
    <span>不男不女</span>
{{# } }}

同样也可嵌套使用:

                  <script type="text/html" id="prizeTpl">
                        {{# if (d.pid ==null) { }}
                        <span class="layui-btn layui-btn-danger layui-btn-mini">未分配</span>
                        {{# } else { }}
                            {{# if (d.is_deal == 0) { }}
                            <span class="layui-btn layui-btn layui-btn-mini">已分配(未领取)</span>
                            {{# } else { }}
                            <span class="layui-btn layui-btn layui-btn-mini">已分配(已领取)</span>
                            {{# } }}
                        {{# } }}
                    </script>


最新回复 (0)
发新帖