import React, {Component} from 'react';
import { Menu, Icon } from 'antd';
import {Link} from 'react-router-dom';
const menuList = [
{
title: '首页', // 菜单标题名称
key: '/home', // 对应的 path
icon: 'home', // 图标名称
},
{
title: '商品',
key: '/products',
icon: 'appstore',
children: [ // 子菜单列表
{
title: '品类管理',
key: '/category',
icon: 'bars'
},
{
title: '商品管理',
key: '/product',
icon: 'tool'
},
]
},
{
title: '用户管理',
key: '/user',
icon: 'user'
},
{
title: '角色管理',
key: '/role',
icon: 'safety',
},
{
title: '图形图表',
key: '/charts',
icon: 'area-chart',
children: [
{
title: '柱形图',
key: '/charts/bar',
icon: 'bar-chart'
},
{
title: '折线图',
key: '/charts/line',
icon: 'line-chart'
},
{
title: '饼图',
key: '/charts/pie',
icon: 'pie-chart'
},
]
},
]; const { SubMenu } = Menu;
class LeftMenu extends Component {
getMenuNodes = (menuList) => {
return menuList.map(item => {
if (!item.children) {
return (
<Menu.Item key={item.key}>
<Link to={item.key}>
<Icon type={item.icon} />
<span>{item.title}</span>
</Link>
</Menu.Item>
);
} else {
return (<SubMenu
key={item.key}
title={
<span>
<Icon type={item.icon} />
<span>{item.title}</span>
</span>
}
>
{
this.getMenuNodes(item.children)
}
</SubMenu>);
}
});
}; render() {
return (
<Menu
defaultSelectedKeys={['1']}
defaultOpenKeys={['sub1']}
mode="inline"
theme="dark"
>
{
this.getMenuNodes(MenuList)
}
</Menu>
)
}
} export default LeftMenu;

最新文章

  1. Android菜单项内容大全
  2. WCF学习之旅—请求与答复模式和单向模式(十九)
  3. DDD~概念中的DDD(转)
  4. fool
  5. vue在多级联动时,一些情况不用watch而用onchange会更好
  6. Struts2 动态结果和带参数的跳转
  7. java web名词解释
  8. Knockout应用开发指南 第一章:入门
  9. struts1.3异常处理机制
  10. Yii PHP 框架分析(三)
  11. java 良好开发规范
  12. MVC验证03-自定义验证规则、禁止输入某些值
  13. 怎样将MySQL数据库上传到服务器
  14. Swift 学习笔记 (一)
  15. ormlite 批处理操作
  16. Linux安装mysql-5.7.17
  17. SpringMV---params and headers
  18. bzoj4514 数字配对
  19. 面向对象—的__new__()方法详解
  20. 解析&lt;button&gt;和&lt;input type=&quot;button&quot;&gt; 的区别

热门文章

  1. ios11返回按钮问题
  2. 使用idea 搭建一个 SpringBoot + Mybatis + logback 的maven 项目
  3. Maven 安装 与 使用
  4. Java-FtpUtil工具类
  5. beautifulsoap常用取节点方法
  6. js中window.event对象
  7. mac 建立 .babellrc 格式文件
  8. Spring Batch 4.2 新特性
  9. 编译报错:File ended while scanning use of xxx
  10. Centos7下设置MySql自动启动