1分钟部署网站📞AI智能客服,大模型训练自有数据,简单好用,有效降低客服成本 广告
# 表格中显示图片 > 在表格里显示图片或者其他东西, 需要用到script模板 ## 效果图 ![](images/screenshot_1568715815732.png) ## 代码 ``` <table class="layui-table" lay-filter="fucker" id="fucker" lay-data="{height: 'full-200'}"> <thead> <tr> <th lay-data="{field:'homestay_id', width:50}">ID</th> <th lay-data="{templet:'#img', width:130}">图片</th> <th lay-data="{field:'title',width:240}">标题</th> <th lay-data="{templet:'#price'}">单价</th> <th lay-data="{templet:function(d) { return (d.is_fenqi==1?'√':'-'); }}">分期</th> <th lay-data="{field:'create_time'}">创建时间</th> </tr> </thead> </table> <!-- 自定义显示内容 --> <script type="text/html" id="price"> <p>¥{{d.price}}</p> <p>¥<s>{{d.raw_price}}</s></p> </script> <!-- 显示图片 d 就是当前行的数据 --> <script type="text/html" id="img"> <img src="{{d.first_img}}" alt="" style="width:100px;height:100px;"> </script> ```