使用http://bootstrap-table.wenzhixin.net.cn
这是我的包含表格代码的组件:
var Component = React.createClass({
render: function() {
return (
<div className="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">
<div className="row">
<ol className="breadcrumb">
<li><a href="#"><span className="glyphicon glyphicon-home"></span></a></li>
<li className="active">Users</li>
</ol>
</div><!--/.row-->
<div className="row">
<div className="col-lg-12">
<h1 className="page-header">Tables</h1>
</div>
</div><!--/.row-->
<div className="row">
<div className="col-lg-12">
<div className="panel panel-default">
<div className="panel-heading">User List</div>
<div className="panel-body">
<table ref='table' data-toggle="table" data-url='http://localhost:3000/admin/users' data-show-refresh="true" data-show-toggle="true" data-show-columns="true" data-search="true" data-select-item-name="toolbar1" data-pagination="true" data-sort-name="name" data-sort-order="desc">
<thead>
<tr>
<th data-field="firstName">First Name</th>
<th data-field="lastName">Last Name</th>
<th data-field="level">Level</th>
<th data-field="verified">Verified</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div><!--/.row-->
</div><!--/.main-->
);
}
});
如果我直接加载包含此表的页面,它工作正常。但是,如果我使用 react-router 从其他页面转换到该页面,则不会加载该表。看起来好像加载 bootstrap-table.js 的那个被卸载了。