class Demo extends React.Component {
state = {
treeData: []
}
onSearch = (value) => {
GET(`role/queryAccount?empId=${value}`)
.then(res => {
if (res.empId) {
this.setState({
treeData: [{ ...res, label: res.name, value: res.empId, key: res.empId }]
})
}
})
}
render() {
console.log(this.state.treeData)
return (
<TreeSelect
showSearch
style={{ width: 300 }}
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
treeData={this.state.treeData}
placeholder="Please select"
treeDefaultExpandAll
onSearch={this.onSearch}
/>
);
}
}
环境:用的是antd的TreeSelect组件(2.x或者3.x都一样)
现在有这么一个问题:当我使用数字搜索的时候没有问题,但是使用字母搜索就不行了,有数据却不会更新,也会重新render