0

7.5 更新:问题原因是,标签大小写写错了
Menu.item改为Menu.Item,就可以了

三级菜单渲染出错,
报错信息如下:

clipboard.png

warning.js:33 Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check the render method of `LayoutWrap`.
    in LayoutWrap (created by Connector)
    in Connector (created by Connect(Connector))
    in Connect(Connector) (created by App)
    in div (created by App)
    in App (created by Route)
    in Route
    in Switch
    in Router (created by BrowserRouter)
    in BrowserRouter
    in Provider

代码结构如下:

const menuContent = menuGroup.value.map((val, index) => (
      <SubMenu
        key={'sub' + index}
        className={style.menuMargin}
        title={<span><Icon type='user'/><span>{val.name}</span></span>}
      >
        nodes.children ?
        {(val.children || []).map((nodes, num) => (
            <SubMenu
              key={nodes.name}
              className={style.menuMargin}
              title={<span><Icon type='user'/><span>{nodes.name}</span></span>}
            >
              {
                nodes.children.map((value, num) => (
                  <Menu.item
                    onClick={() => this.onHandleClick(value.name)}
                    key={value.name}
                  >
                    <Link to={utils.selectedMenuRouteData(value.name,'toPath')}>{value.name}</Link>
                  </Menu.item>
                ))
              }
            </SubMenu>
            :
            <Menu.Item onClick={() => this.onHandleClick(nodes.name)} key={nodes.name}>
              <Link to={utils.selectedMenuRouteData(nodes.name,'toPath')}>{nodes.name}</Link>
            </Menu.Item>
        ))}
      </SubMenu>
    ));

数据结构如下:

const value= [
    {
      "children": [{
        "children":[{
        "children": null,
        "icon": "",
        "id": 1,
        "ismenu": 1,
        "levels": 3,
        "name": "子部门管理",
        "num": 1,
        "parentId": 0,
        "url": null
      }],
        "icon": "",
        "id": 1,
        "ismenu": 1,
        "levels": 2,
        "name": "公司管理",
        "num": 1,
        "parentId": 0,
        "url": null
      }, {
        "children": null,
        "icon": "",
        "id": 1,
        "ismenu": 1,
        "levels": 2,
        "name": "部门管理",
        "num": 1,
        "parentId": 0,
        "url": null
      }, {
        "children": null,
        "icon": "",
        "id": 1,
        "ismenu": 1,
        "levels": 2,
        "name": "职位管理",
        "num": 1,
        "parentId": 0,
        "url": null
      }, {
        "children": null,
        "icon": "",
        "id": 1,
        "ismenu": 1,
        "levels": 2,
        "name": "用户管理",
        "num": 1,
        "parentId": 0,
        "url": null
      }],
      "icon": "",
      "id": 1,
      "ismenu": 1,
      "levels": 1,
      "name": "SSO管理",
      "num": 1,
      "parentId": 0,
      "url": null
    }]

请问是什么原因呢?

2018-07-05 提问
1 个回答
0

已采纳

Menu.item改成Menu.Item……

撰写答案

你可能感兴趣的

推广链接