ant-design/components/menu/demo/horizontal.md

66 lines
1.5 KiB
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 0
title:
zh-CN: 顶部导航
en-US: Top Navigation
2016-03-31 09:40:55 +08:00
---
## zh-CN
水平的顶部导航菜单。
## en-US
Horizontal top navigation menu.
2017-02-13 10:55:53 +08:00
````jsx
import { Menu, Icon } from 'antd';
const SubMenu = Menu.SubMenu;
2015-12-11 16:55:30 +08:00
const MenuItemGroup = Menu.ItemGroup;
const App = React.createClass({
getInitialState() {
return {
2016-05-06 18:07:23 +08:00
current: 'mail',
};
},
2015-08-15 00:07:40 +08:00
handleClick(e) {
console.log('click ', e);
this.setState({
2016-05-06 18:07:23 +08:00
current: e.key,
});
},
render() {
2015-11-14 17:29:48 +08:00
return (
<Menu
onClick={this.handleClick}
2015-11-14 17:29:48 +08:00
selectedKeys={[this.state.current]}
mode="horizontal"
>
2015-11-14 17:29:48 +08:00
<Menu.Item key="mail">
<Icon type="mail" />Navigation One
2015-11-14 17:29:48 +08:00
</Menu.Item>
<Menu.Item key="app" disabled>
<Icon type="appstore" />Navigation Two
2015-11-14 17:29:48 +08:00
</Menu.Item>
<SubMenu title={<span><Icon type="setting" />Navigation Three - Submenu</span>}>
<MenuItemGroup title="Item 1">
<Menu.Item key="setting:1">Option 1</Menu.Item>
<Menu.Item key="setting:2">Option 2</Menu.Item>
2015-12-11 16:55:30 +08:00
</MenuItemGroup>
<MenuItemGroup title="Item 2">
<Menu.Item key="setting:3">Option 3</Menu.Item>
<Menu.Item key="setting:4">Option 4</Menu.Item>
2015-12-11 16:55:30 +08:00
</MenuItemGroup>
2015-11-14 17:29:48 +08:00
</SubMenu>
<Menu.Item key="alipay">
2016-09-30 18:13:22 +08:00
<a href="https://ant.design" target="_blank" rel="noopener noreferrer">Navigation Four - Link</a>
2015-11-14 17:29:48 +08:00
</Menu.Item>
</Menu>
);
2016-05-11 09:32:33 +08:00
},
});
ReactDOM.render(<App />, mountNode);
````