期望效果:
相关代码:
<script type="text/html" id="number">
<div style="line-height:25px;">
<span style="color:#328FFE">{{ d.Nownumber }}</span>
<p style="color:#BCBBC9;margin-top:-5px;">(卡号:{{ d.Oldnumber }})</p>
</div>
</script>
<!--时间合并-->
<script type="text/html" id="time">
<div style="line-height:25px;">
<span>{{ d.Day }}</span>
<p style="color:#BCBBC9;margin-top:-5px;">{{ d.Hour }}</p>
</div>
</script>
<script>
layui.use('table', function () {
var table = layui.table;
var cols = [[
, {field: 'Day', title: '时间', templet: '#time',align: 'center'}
, {field: 'Number', title: '流水号', templet: '#number', width: 150,align: 'center'}
]];
table.render({
elem: '#history-basic'
, url: '../json/history-basic.json'
, cols: cols
, even: true
,skin:"line"
, page: true
});
});
</script>
代码注释:
对JSON数据进行判断
<script type="text/html" id="type">
{{# if(d.Type === '撤销消费'){ }}
<span style="color: #FF0000;">{{ d.Type }}</span>
{{# } else { }}
{{ d.Type }}
{{# } }}
</script>