如果我在 javascript 中设置列​​,bootstrap-table 调整列大小不起作用

bootstrap-table resize column not work if I set columns in javascript

我正在使用以下示例来执行可调整大小的列:

https://live.bootstrap-table.com/example/extensions/resizable.html

如果我按照 link 示例那样做,请在 thead 中设置列​​:

<table id="table"

  data-url="json/data1.json"
  data-resizable="true">
  <thead>
    <tr>
      <th data-field="id" data-width="18">ID</th>
      <th data-field="name" data-width="20">Item Name</th>
      <th data-field="price" data-width="25">Item Price</th>
    </tr>
  </thead>
</table>

<script>
  $(function() {
    $('#table').bootstrapTable()
  })

然后我可以调整列的大小。

但是,如果我在 js 中设置列​​,例如:

<table id="table"

  data-url="json/data1.json"
  data-resizable="true">

</table>

<script>
  var defaultColumns = [        
        {title: 'Id', field: 'id', width: 180},
        {title: 'Name', field: 'name', width: 100},
        {title: 'Price', field: 'price', width: 180}            
        ];

  $(document).ready(function() {

    $( '#table' ).bootstrapTable(

        {columns: defaultColumns}
    );
  });

然后我无法调整列的大小。

如果在js中设置列,如何调整列的大小?

这已在本 pull request

中修复