2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 0
|
|
|
|
title: 顶部导航
|
|
|
|
---
|
2015-08-14 18:16:41 +08:00
|
|
|
|
|
|
|
水平的顶部导航菜单。
|
|
|
|
|
|
|
|
````jsx
|
2015-11-25 17:35:49 +08:00
|
|
|
import { Menu, Icon } from 'antd';
|
2015-10-28 20:55:49 +08:00
|
|
|
const SubMenu = Menu.SubMenu;
|
2015-12-11 16:55:30 +08:00
|
|
|
const MenuItemGroup = Menu.ItemGroup;
|
2015-08-14 18:16:41 +08:00
|
|
|
|
2015-10-28 20:55:49 +08:00
|
|
|
const App = React.createClass({
|
2015-08-14 18:16:41 +08:00
|
|
|
getInitialState() {
|
|
|
|
return {
|
2016-05-06 18:07:23 +08:00
|
|
|
current: 'mail',
|
2015-11-25 17:35:49 +08:00
|
|
|
};
|
2015-08-14 18:16:41 +08:00
|
|
|
},
|
2015-08-15 00:07:40 +08:00
|
|
|
handleClick(e) {
|
|
|
|
console.log('click ', e);
|
2015-08-14 18:16:41 +08:00
|
|
|
this.setState({
|
2016-05-06 18:07:23 +08:00
|
|
|
current: e.key,
|
2015-08-14 18:16:41 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
render() {
|
2015-11-14 17:29:48 +08:00
|
|
|
return (
|
|
|
|
<Menu onClick={this.handleClick}
|
|
|
|
selectedKeys={[this.state.current]}
|
2016-06-06 13:54:10 +08:00
|
|
|
mode="horizontal"
|
|
|
|
>
|
2015-11-14 17:29:48 +08:00
|
|
|
<Menu.Item key="mail">
|
|
|
|
<Icon type="mail" />导航一
|
|
|
|
</Menu.Item>
|
2015-12-04 11:22:16 +08:00
|
|
|
<Menu.Item key="app" disabled>
|
2015-11-14 17:29:48 +08:00
|
|
|
<Icon type="appstore" />导航二
|
|
|
|
</Menu.Item>
|
|
|
|
<SubMenu title={<span><Icon type="setting" />导航 - 子菜单</span>}>
|
2015-12-11 16:55:30 +08:00
|
|
|
<MenuItemGroup title="分组1">
|
|
|
|
<Menu.Item key="setting:1">选项1</Menu.Item>
|
|
|
|
<Menu.Item key="setting:2">选项2</Menu.Item>
|
|
|
|
</MenuItemGroup>
|
|
|
|
<MenuItemGroup title="分组2">
|
|
|
|
<Menu.Item key="setting:3">选项3</Menu.Item>
|
|
|
|
<Menu.Item key="setting:4">选项4</Menu.Item>
|
|
|
|
</MenuItemGroup>
|
2015-11-14 17:29:48 +08:00
|
|
|
</SubMenu>
|
|
|
|
<Menu.Item key="alipay">
|
|
|
|
<a href="http://www.alipay.com/" target="_blank">导航四 - 链接</a>
|
|
|
|
</Menu.Item>
|
|
|
|
</Menu>
|
|
|
|
);
|
2016-05-11 09:32:33 +08:00
|
|
|
},
|
2015-08-14 18:16:41 +08:00
|
|
|
});
|
|
|
|
|
2015-12-29 12:08:58 +08:00
|
|
|
ReactDOM.render(<App />, mountNode);
|
2015-08-14 18:16:41 +08:00
|
|
|
````
|