主要代码如下,但是渲染出来的tree是全部关闭的,请问如何解决?谢谢~
componentDidMount() {
// 获取TreeData
getTreeData = (appId) => {
const { dispatch } = this.props;
const { selectedKeys } = this.state;
dispatch({
type: "auth/getTreeData",
payload: {
appId, // 测试数据
},
callback: (data) => {
if(data.isSuccess){
this.setState({ //修改state的值
treeData: data.res,
});
}
},
});
}
}
//render方法
<Tree
defaultExpandAll
onSelect={this.onSelect}
>
{this.renderTreeNode(treeData)}
</Tree>
获取到数据后再渲染tree,没数据时不渲染tree