--- order: 2 title: 只展开当前父级菜单 --- 点击菜单,收起其他展开的所有菜单,保持菜单聚焦简洁。 ````jsx import { Menu, Icon } from 'antd'; const SubMenu = Menu.SubMenu; const Sider = React.createClass({ getInitialState() { return { current: '1', openKeys: [], }; }, handleClick(e) { console.log('click ', e); this.setState({ current: e.key, openKeys: e.keyPath.slice(1), }); }, onToggle(info) { this.setState({ openKeys: info.open ? info.keyPath : info.keyPath.slice(1), }); }, render() { return (
); }, }); ReactDOM.render(