代码如下
render() {
...
const columns = [
{
title: "序号",
dataIndex: "number",
key: "number"
},
{
title: "用户ID",
dataIndex: "category",
key: "category",
render: (text, record) =>
this.renderUserColumns(text, record, "category"),
filterDropdown: (
<div className="custom-filter-dropdown">
<Input
ref={ele => {
this.searchInput = ele;
}}
placeholder="搜索用户"
value={this.state.searchText}
onChange={this.onInputChange}
onPressEnter={this.onSearch}
/>
<Button type="primary" onClick={this.onSearch}>
搜索
</Button>
</div>
),
filterIcon: (
<Icon
type="search"
style={{ color: this.state.filtered ? "#108ee9" : "#aaa" }}
/>
),
filterDropdownVisible: this.state.filterDropdownVisible,
onFilterDropdownVisibleChange: visible => {
this.setState(
{
filterDropdownVisible: visible
},
() => this.searchInput.focus()
);
}
},
...
用的antd的表头自定义功能
callback不是在setState调用之后再执行吗?当我的filterDropdownVisible更新后this.searchInput才会存在,但是callback并没有在setState调用之后执行
已解决