这里有固定数据表示例:
https://github.com/facebook/fixed-data-table/blob/master/examples/FilterExample.js
但我很难理解这一点。
我用ES5写了一些关于固定数据表的代码。现在我想把“过滤”示例放到我的代码中。但是这个例子是ES6。
您能帮助我理解或如何将ES6转换为ES5。
这是我的代码:
var rows = [{"id":1,"first_name":"William","last_name":"Elliott","email":"welliott0@wisc.edu",
"country":"Argentina","ip_address":"247.180.226.89"},
{"id":2,"first_name":"Carl","last_name":"Ross","email":"cross1@mlb.com",
"country":"South Africa","ip_address":"27.146.70.36"},
{"id":3,"first_name":"Jeremy","last_name":"Scott","email":"jscott2@cbsnews.com",
"country":"Colombia","ip_address":"103.52.74.225"},
// more data
];
ReactDOM.render(
<Table
height={rows.length * 30}
width={1150}
rowsCount={rows.length}
rowHeight={30}
headerHeight={30}
rowGetter={function(rowIndex) {return rows[rowIndex]; }}>
<Column dataKey="id" width={50} label="Id" />
<Column dataKey="first_name" width={200} label="First Name" />
<Column dataKey="last_name" width={200} label="Last Name" />
<Column dataKey="email" width={400} label="e-mail" />
<Column dataKey="country" width={300} label="Country" />
</Table>,
document.getElementById('root')
);
答案 0 :(得分:2)
您可以使用React.createClass
,而不是使用&#39;类&#39;。这是一个例子:
var FilterExample = React.createClass({
// constructor
getInitialState: function() {
this._dataList = new FakeObjectDataListStore(2000);
this._onFilterChange = this._onFilterChange.bind(this);
return {
filteredDataList: this._dataList,
};
},
...
render: function() {
<Table
...
</Table>,
document.getElementById('root')
}
});