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

45 lines
1.0 KiB
Markdown
Raw Normal View History

# 顶部导航
- order: 0
水平的顶部导航菜单。
---
````jsx
var Menu = antd.Menu;
var SubMenu = Menu.SubMenu;
var App = React.createClass({
getInitialState() {
return {
current: 'mail'
}
},
2015-08-15 00:07:40 +08:00
handleClick(e) {
console.log('click ', e);
this.setState({
2015-08-15 00:07:40 +08:00
current: e.key
});
},
render() {
return <Menu onClick={this.handleClick} selectedKeys={[this.state.current]} mode="horizontal">
<Menu.Item key="mail">
<i className="anticon anticon-mail"></i>导航一
</Menu.Item>
<Menu.Item key="app">
<i className="anticon anticon-large"></i>导航二
</Menu.Item>
<SubMenu title={<span><i className="anticon anticon-setting"></i>导航三(子菜单)</span>}>
<Menu.Item key="setting:1">选项1</Menu.Item>
<Menu.Item key="setting:2">选项2</Menu.Item>
<Menu.Item key="setting:3">选项3</Menu.Item>
<Menu.Item key="setting:4">选项4</Menu.Item>
</SubMenu>
</Menu>
}
});
React.render(<App />, document.getElementById('components-menu-demo-horizontal'));
````