代码之家  ›  专栏  ›  技术社区  ›  theJuls

包装React语义UI菜单。锚标记中的项,而不破坏其样式

  •  1
  • theJuls  · 技术社区  · 8 年前

    我有一个React语义Ui菜单,它必须链接到另一个页面。 我试图用一个锚标记来包装它,但这完全破坏了菜单按钮上的样式。在假设是但是之前,我想我是做错了。

    这就是我的代码当前的样子:

    <Menu tabular attached='top'>
       <a href={item1Url}><Menu.Item link>item1</Menu.Item></a>
       <a href={item2Url}><Menu.Item active link>Item 2</Menu.Item></a>
    </Menu>
    

    在包装之前 Menu.Item a 标签,这是它现在的样子:

    enter image description here

    标签包装它,它看起来像这样:

    enter image description here

    更不用说当我在上面盘旋的时候它就完全消失了。我做错什么了吗?

    1 回复  |  直到 8 年前
        1
  •  2
  •   ChrisR    8 年前

    如果你看看 the doc ,您可以直接添加 href (和 target )属性到 Menu.Item 元素。

    在您的情况下,结果将是:

    <Menu tabular attached='top'>
       <Menu.Item href="item1Url">item1</Menu.Item></a>
       <Menu.Item href="item2Url"active>Item 2</Menu.Item></a>
    </Menu>