我有以下几点:
如何去掉蓝色下划线? 代码如下:
<Link to="first"><MenuItem style={{paddingLeft: 13, textDecoration: 'none'}}> Team 1 </MenuItem></Link>
MenuItem组件来自http://www.material-ui.com/#/components/menu
我有以下几点:
如何去掉蓝色下划线? 代码如下:
<Link to="first"><MenuItem style={{paddingLeft: 13, textDecoration: 'none'}}> Team 1 </MenuItem></Link>
MenuItem组件来自http://www.material-ui.com/#/components/menu
当前回答
我发现这个问题,在一般情况下,没有一个答案真正解决了这个问题(例如,如果元素不是一个菜单项)。我建议:
import {useHistory} from "react-router-dom";
const MyComp = () => {
const history = useHistory();
return <div>
<AnyComponent onclick={()=>history.push('/path/u/want')}
</div>
}
其他回答
还有另一种方法可以正确地删除链接的样式。你必须给它的textDecoration='inherit'和color='inherit'的风格,你可以添加这些作为样式的链接标签,如:
<Link style={{ color: 'inherit', textDecoration: 'inherit'}}>
或者为了使它更通用,只需创建一个CSS类:
.text-link {
color: inherit;
text-decoration: inherit;
}
然后只需<Link className='text-link'>
style={{ backgroundImage: "none" }}
只有这对我有用
/ / CSS
.navigation_bar > ul > li {
list-style: none;
display: inline;
margin: 2%;
}
.link {
text-decoration: none;
}
.jsx
<div className="navigation_bar">
<ul key="nav">
<li>
<Link className="link" to="/">
Home
</Link>
</li>
</ul>
</div>
为我工作,只需添加className="nav-link"和activeStyle{{textDecoration:'下划线'}}
<NavLink className="nav-link" to="/" exact activeStyle=
{{textDecoration:'underline'}}>My Record</NavLink>
添加css样式
a:link {
text-decoration: none;
color: #cc850a;
}
a:visited {
text-decoration: none;
color: #cc850a;
}
a:hover {
text-decoration: none;
color: #47a1ad;
}
a:active {
text-decoration: none;
}