react使用antd组件递归实现左侧菜单导航树

import React from 'react'
import { Menu, Icon } from 'antd';
import './index.less';
import MenuConfig from './../../config/menuconfig';  //导入数据
const SubMenu = Menu.SubMenu;

export default class NavLeft extends React.Component{
  componentWillMount() {
    const menuTreeNode = this.renderMenu(MenuConfig);
    this.setState({
      menuTreeNode
    })
  }
  // 菜单渲染
renderMenu = (data) => {
  return data.map((item)=>{
    if(item.children){
      return 
      { this.renderMenu(item.children) }
      
    }
    return {item.title}
  })
}
  render() {
    return(
      

MS

{this.state.menuTreeNode}
) } }

你可能感兴趣的:(antd,递归菜单,react)