一,table表格數據,樣式設置
1,方法一,直接在對應列上設置好style:
如下給列“類型”添加了字體顏色#f67d06
layList.tableList('userList',"{:Url('getlist')}",function () {
return [
{field: 'type', title: '類型' ,style:'color: #f67d06;'},
{field: 'title', title: '標題' },
{field: 'balance', title: '餘量',sort:true,event:'balance'},
{field: 'number', title: '獎勵',sort:true},
{field: 'mark', title: '備註'},
{field: 'nickname', title: '微信暱稱/操作者'},
{field: 'add_time', title: '時間',align:'center'},
];
});
2,方法二,使用templete,
可以在script標籤裏寫html代碼,什麼a標籤,span標籤,class和style都可以寫。
layList.tableList('userList',"{:Url('getlist')}",function () {
return [
{field:'type',title: '類型',templet: '#typecolor'}",
{field: 'title', title: '標題' },
{field: 'balance', title: '餘量',sort:true,event:'balance'},
{field: 'number', title: '獎勵',sort:true},
{field: 'mark', title: '備註'},
{field: 'nickname', title: '微信暱稱/操作者'},
{field: 'add_time', title: '時間',align:'center'},
];
});
<script type="text/html" id="typecolor">
<a href="https://blog.csdn.net/weixin_43687896/article/details/84344089" class="background" target="_blank" style="color:#f67d06;">{{ d.username }}</a>
</script>
直接在對應的模板上設置各種結構和樣式,較上面一種更加的靈活,不但可以設置樣式,還可以更改特別的結構
方法三,(在數據返回前做好處理,也就是寫入html代碼),直接在後端php拼接好返回數據結構
在模型裏處理要返回的數據(在數據上拼接html代碼)
$list[$key]['type'] = "<span style='color: #f67d06;'>".$list[$key]['type']."</span>";
參考博客位置:https://blog.csdn.net/weixin_43687896/article/details/84976821