操作autoExpandParent和expandCode
state = {
autoExpandParent: true,
}
// 展开缩起触发
expand (key,label) {
this.setState({
autoExpandParent: false,
})
// 保存受控的expandCode
this.props.dispatch({
type: '***save',
payload: {
expandCode: key
}
})
}
renderTreeNodes() {
// render treenodes
}
// render
render() {
return (
<div>
{
treeData && treeData.length > 0 ?
<Tree
autoExpandParent={autoExpandParent}
expandedKeys={expandCode}
onExpand={(key,label)=>{this.expand(key,label)}}
>
{this.renderTreeNodes(newTreeData)}
</Tree> : ''
}
</div>
)
}
网友评论