[英]Wrap React Semantic-UI Menu.Item in anchor tag without ruining it styles
I have a React Semantic Ui menu which has to link to another page. 我有一个React Semantic Ui菜单,它必须链接到另一个页面。 I am trying to wrap it with an anchor tag, but this completely breaks the styles on the menu buttons.
我正在尝试用锚标记包装它,但这完全破坏了菜单按钮上的样式。 I would like to think I'm doing something wrong before assuming it's a but.
我想以为我在做错某事之前就做错了。
This is what my code currently looks like: 这是我的代码当前的样子:
<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>
Before wrapping the Menu.Item
with the a
tag, this is what it currently looked like: 在使用
a
标签包装Menu.Item
之前,这是当前的样子:
With the a
tag wrapping it, it looks like this: 随着
a
标签包装它,它看起来像这样:
Not to mention that it disappears completely when I hover on it. 更不用说当我将鼠标悬停在上面时它会完全消失。 Am I doing something wrong?
难道我做错了什么?
If you look at the doc , you can directly add the href
(and target
) attributes to the Menu.Item
element. 如果您查看doc ,则可以将
href
属性(和target
)直接添加到Menu.Item
元素。
In your case the result would be: 在您的情况下,结果将是:
<Menu tabular attached='top'>
<Menu.Item href="item1Url">item1</Menu.Item></a>
<Menu.Item href="item2Url"active>Item 2</Menu.Item></a>
</Menu>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.