【问题标题】:Unable to display actual material-ui icon within my nav menu无法在我的导航菜单中显示实际的 Material-ui 图标
【发布时间】: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?请发布一个最小的可重现代码。

标签: javascript arrays material-ui icons html-escape-characters


【解决方案1】:

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

  const menuList = [];

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-15
    • 1970-01-01
    • 2022-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-09
    相关资源
    最近更新 更多