鍍金池/ 問答/HTML/ antd的TreeSelect 的搜索框作異步請(qǐng)求然后更新treeData

antd的TreeSelect 的搜索框作異步請(qǐng)求然后更新treeData

很奇怪的我問題,當(dāng)我使用數(shù)字搜索的時(shí)候沒有問題,但是使用字母搜索就不行了,有數(shù)據(jù)卻不會(huì)更新,會(huì)重新render
環(huán)境:antd: 2.x或者3.x都是這樣

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}
            />

         
        );
    }
}
回答
編輯回答
傻丟丟

不行了?是什么情況?
異常是什么?
就這段代碼是看不出問題的。

2017年11月4日 00:32