无法在我的导航菜单中显示实际的 Material-ui 图标

Posted

技术标签:

【中文标题】无法在我的导航菜单中显示实际的 Material-ui 图标【英文标题】:Unable to display actual material-ui icon within my nav menu 【发布时间】:2021-10-14 19:15:28 【问题描述】:

使用像<AddOutlinedIcon />这样的Material-UI图标,如下所示,我怎样才能真正使图标出现在我的导航菜单中,因为它在我的菜单名称之前显示标签/单词<AddOutlinedIcon />

不确定我是否需要转义以显示实际图标?

它实际上应该在我的菜单名称前显示一个+ 图标。

  const menuList = [];

  myMenu.map(menuListItem =>
    menuList.push(
      id: menuListItem.manu_name,
      icon: '<AddOutlinedIcon />',          
      active: false
    )
  )

【问题讨论】:

nit:您可以将map 更改为forEach 您如何使用menuList?请发布一个最小的可重现代码。 【参考方案1】:

您是否尝试过将 AddOutlinedIcon 作为字符串值删除?

  const menuList = [];

  myMenu.map(menuListItem =>
    menuList.push(
      id: menuListItem.manu_name,
      icon: <AddOutlinedIcon />,          
      active: false
    )
  )

【讨论】:

以上是关于无法在我的导航菜单中显示实际的 Material-ui 图标的主要内容,如果未能解决你的问题,请参考以下文章