更新时间:2023-12-04 11:57:28
是的,这确实很烦人.不使用引导程序也是如此,即使您声明了className
,也始终添加.dt-button
.您可以使用 init
回调修改示例类:
Yes, this can be really annoying. It is the same without using bootstrap, where .dt-button
always is added even if you declare className
. There is a init
callback you can use to modify for example classes :
$('#example').DataTable( {
dom: 'Bfrtip',
buttons: [{
extend: "excel",
className: "btn-sm btn-success",
titleAttr: 'Export in Excel',
text: 'Excel',
init: function(api, node, config) {
$(node).removeClass('btn-default')
}
}]
});
演示-> https://jsfiddle.net/m6hysypd/
demo -> https://jsfiddle.net/m6hysypd/
更新:对此已经获得了很多好评,但是正确或*** 答案实际上是"DavidDomains"的答案,以下.使用
Update: Have received a lot of upvotes on this, but the correct or best answer is actually "DavidDomains"'s answer below. Use
buttons: {
dom: {
button: {
className: ''
}
},
buttons: [{
//here comes your button definitions
}]
}