bootstrap table給行怎么加背景色
bootstrap table定義代碼:
$table.bootstrapTable({ showExport: true, height: 540, rowStyle:rowStyle,//通過自定義函數(shù)設(shè)置行樣式 columns: [ { field: 'id', title: '序號', align: 'center', sortable: true }, { field: 'sid', title: '學號', align: 'center' }, ] });
bootstrapTable設(shè)置行樣式(背景顏色)函數(shù)1:通過調(diào)用bootstrap默認的樣式來設(shè)置指定行的背景顏色
function rowStyle(row, index) { var classes = ['active', 'success', 'info', 'warning', 'danger']; if (index % 2 === 0 && index / 2 < classes.length) { return { classes: classes[index / 2] }; } return {}; }
bootstrapTable設(shè)置行樣式(背景顏色)函數(shù)2:調(diào)用自定義樣式設(shè)置指定行的字體顏色
function rowStyle(row, index) { var style = {}; style={css:{'color':'#ed5565'}}; return style; }