🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 模板中使用JS表达式 > 不可避免的需要用到, if else 判断 ``` <table class="layui-table" lay-data="{ url:'{:url(\'list\')}', id:'idTest'}" lay-filter="demo"> <thead> <tr> <th lay-data="{templet:'#code'}">类型</th> <th lay-data="{field:'create_time'}">创建时间</th> </tr> </thead> </table> <script type="text/html" id="code"> {{# if (d.code == 'goods') { }} 商品 {{# } else if (d.code == 'homestay') { }} 酒店 {{# } else if (d.code == 'story') { }} 故事 {{# } }} </script> ``` 用 `{{# }}` 把js表达式圈起来