demo: https://stackblitz.com/edit/r...
做成受控组件,使用expandedKeys控制展开节点,通过onExpand接收事件,然后更新expandedKeys,类似于
const [expandedKeys, setExpandedKeys] = useState([])
// ...
<Tree
expandedKeys={expandedKeys}
onExpand={(_expandedKeys, {nativeEvent}) => {
// if event from icon
setExpandedKeys(_expandedKeys)
}
}
/>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…