// expandedKeys,selectedKeys 使用了这两个方法,发现树形结构点击不能收缩,必须要把父级目录parent 1-0下的第二个leaf点击让背景色消失才会自动收缩,这样自动收缩也是不对的,即使点击让背景色消失也不能自动收缩,直到用户点击父级parent 1-0才能收缩,这才正常,求解答

checkedKeys = () => {
this.setState({ checkedKey: ['0-0-0-1','0-0-1-0'] });
}
onSelect = (selectedKeys, info) => {
this.setState({ checkedKey: selectedKeys });
}
onExpands = (selectedKeys, info) => {
this.setState({ checkedKey: selectedKeys });
}
render() {
return (
<div>
<Tree
multiple={true}
expandedKeys={this.state.checkedKey}
selectedKeys={this.state.checkedKey}
onSelect={this.onSelect}
onExpand={this.onExpands}
>
<TreeNode title="parent 1" key="0-0">
<TreeNode title="parent 1-0" key="0-0-0">
<TreeNode title="leaf" key="0-0-0-0" />
<TreeNode title="leaf" key="0-0-0-1" />
</TreeNode>
<TreeNode title="parent 1-1" key="0-0-1">
<TreeNode title="sss" key="0-0-1-0" />
</TreeNode>
</TreeNode>
</Tree>
<button onClick={this.checkedKeys}>给复选框值</button>
</div>
);
}
这里写错了,checkedKey和expandKey用两个变量来存,他们是两个东西