在使用BootstrapTable时,在没有设置height属性时一切正常,表格对齐也没有问题。
但是为了页面效果,我们会将表格高度固定,将页面撑开,使数据少的时候,页面不显得空荡
height: $(window).height()*0.9,
此时就会出现表格不对齐的现象
解决方法:
打开bootstrap-table.js 找到 BootstrapTable.prototype.resetView方法,找到如下代码,注释掉:
if (this.options.showHeader && this.options.height) {
this.$tableHeader.show();
// 注释掉下面两行 取消表头初始化解决表头和内容不对齐问题
//this.resetHeader();
//padding += this.$header.outerHeight();
}