我有以下几点:

如何去掉蓝色下划线? 代码如下:

<Link to="first"><MenuItem style={{paddingLeft: 13, textDecoration: 'none'}}> Team 1 </MenuItem></Link>

MenuItem组件来自http://www.material-ui.com/#/components/menu


当前回答

我有一个问题,链接元素将我的h4更改为“下划线”,设置文本装饰:“none”不起作用,我唯一的解决方案是使用按钮。

<Link to="/settings">
    <button>Settings</button>
</Link>

其他回答

我发现这个问题,在一般情况下,没有一个答案真正解决了这个问题(例如,如果元素不是一个菜单项)。我建议:

import {useHistory} from "react-router-dom";
const MyComp = () => {
  const history = useHistory();
  return <div>
    <AnyComponent onclick={()=>history.push('/path/u/want')}
  </div>
}
a:-webkit-any-link {
  text-decoration: none;
  color: inherit;
}

看这里-> https://material-ui.com/guides/composition/#button。

这是官方的材质界面指南。也许它对你会像对我一样有用。

然而,在某些情况下,下划线仍然存在,您可能需要使用text-decoration: "none"。为了更简洁的方法,您可以从material-ui/core导入并使用makestyle。

import { makeStyles } from '@material-ui/core';

const useStyles = makeStyles(() => ({
    menu-btn: {
        textDecoration: 'none',
    },
}));

const classes = useStyles();

然后将className属性设置为{classes。menu-btn}在JSX代码中。

<Link 
   _hover={{
      textDecoration: "none"
   }}
   >
   Logo
</Link>

我解决了一个像你这样的问题。我试着在firefox中检查元素。 我将向你们展示一些结果:

这只是我检查过的元素。“Link”组件将被转换为“a”标签,“to”道具将被转换为“href”属性:

当我点击:hov和选项:hover,这里是结果:

如你所见:悬停有文字装饰:下划线。我只添加到我的css文件:

a:hover {
 text-decoration: none;
}

问题就解决了。但我也在一些其他类(比如你:D)设置了text-decoration: none,这可能会产生一些效果(我猜)。