1.后台传来的数据
{ "code": 200, "checkRecords": [ { "id": "402881e75cc8060e015cc835315b0006", "checkAt": 1498007548250, "checkUserId": "402888745c99ba1e015c99ba3d1f0000", "checkUser": { "id": "402888745c99ba1e015c99ba3d1f0000", "name": "admin", "age": null, "email": "107888888@qq.com", "phone": "18602758888", "gender": "MAN", "address": null }, "status": "UN_PASSED", "unPassReason": "审核失败原因2;审核失败原因3;", } } ] }
2.页面模版
<tbody id="lists">
<script type="text/html" id="checkrecords">
{{if checkRecords.length==0}}
<tr>
<td colspan="5">无审核记录</td>
</tr>
{{/if}}
{{if checkRecords.length>0}}
{{each checkRecords as item}}
<tr>
<td>{{item.checkUser.name}}</td>
<td>{{item.checkUser.email}}</td>
<td>
{{if item.status=='PASSED'}}
通过
{{/if}}
{{if item.status=='FOR_CHECK'}}
通过
{{/if}}
{{if item.status=='UN_PASSED'}}
驳回
{{/if}}
</td>
<td>{{item.unPassReason}}</td>
<td>{{item.checkAt | dateFmt}}</td>
</tr>
{{/each}}
{{/if}}
</script>
</tbody>
3.脚本
var html = template('checkrecords',data); $("#lists").html(html);