提交 d8ea555e 编写于 作者: B Benjy Cui

docs: update menu demo

上级 a3962d58
......@@ -29,19 +29,26 @@ const Sider = React.createClass({
};
},
handleClick(e) {
console.log('click ', e);
console.log('Clicked: ', e);
this.setState({ current: e.key });
},
onOpenChange(openKeys) {
const latestOpenKey = openKeys.find(key => !(this.state.openKeys.indexOf(key) > -1));
this.setState({ openKeys: this.getKeyPath(latestOpenKey) });
const state = this.state;
const latestOpenKey = openKeys.find(key => !(state.openKeys.indexOf(key) > -1));
const latestCloseKey = state.openKeys.find(key => !(openKeys.indexOf(key) > -1));
let nextOpenKeys = [];
if (latestOpenKey) {
nextOpenKeys = this.getAncestorKeys(latestOpenKey).concat(latestOpenKey);
}
if (latestCloseKey) {
nextOpenKeys = this.getAncestorKeys(latestCloseKey);
}
this.setState({ openKeys: nextOpenKeys });
},
getKeyPath(key) {
getAncestorKeys(key) {
const map = {
sub1: ['sub1'],
sub2: ['sub2'],
sub3: ['sub2', 'sub3'],
sub4: ['sub4'],
sub3: ['sub2'],
};
return map[key] || [];
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册