一、设置相对应table数据
var tableData = [
{
id: 1,
id8: 'yellow',
id9: 'xxxxx',
}, {
id: 2,
id8: 'red',
id9: 'xxxxx',
}];
二、设置相对应table数据
function initTable() {
$('#table').bootstrapTable({
pagination: true,
checkbox:true,
striped: true,
rowStyle:rowStyle,//通过自定义函数设置行样式
columns: [
{
field: 'id',
title: '序号'
}, {
field: 'id8',
title: 'xxx'
}, {
field: 'id9',
title: 'xxx'
}
],
data:tableData
})
}
三、每行的样式
function rowStyle(row,index) {
var style = {};
if(row.id8){
style={css:{'color':row.id8}};
}
return style;
}
四:最终效果
![]()