演示数据
{ "code": 0, "data": [{ "id": "666666", "num": 0, "pic": "https://www.kxblogs.cn/wp-content/uploads/2020/12/kxblogs-logo.png", "content": [{ "name": "开心Blogs", "remarks": "什么都没有留下" }], "status": 1, "type": 0, "value": 30 }] }
代码笔记
<table class="layui-table" lay-data="{url:'/test', page:false, id:'test'}" lay-filter="test"> <thead> <tr> <th lay-data="{field:'id'}">ID</th> <th lay-data="{field:'condition'}">活动规则</th> <th lay-data="{field:'num'}">商品总数</th> <th lay-data="{field:'content',templet: function(data){console.log(data); return data.content[0].name}}">用户昵称</th> <th lay-data="{field:'content',templet: function(data){console.log(data); return data.content[0].remarks}}">用户签名</th> <th lay-data="{field:'value'}">商品价值</th> <th lay-data="{field:'pic'}">商品图片</th> <th lay-data="{field:'type'}">商品类型</th> <th lay-data="{field:'status',hide:true}">商品状态</th> </tr> </thead> </table>
代码中console.log(data);
主要用于调试内容,可根据Console输出去看json字符串,完成后可删除