React-router/CSS 如果 link 处于活动状态,则没有悬停样式

React-router/CSS no hover-style if link is active

我已经使用 react-router v4 设置了样式导航。使用此代码更改基于悬停和活动作品的样式。但是,如果我将鼠标悬停在(反应路由器)活动 link 上,我确实想禁用悬停样式。我怎样才能做到这一点?

这是我当前的代码:

  <div className="App-navbar">
    <NavLink className="inactive" activeClassName="activeLink" exact to="/">
      Home
    </NavLink>
    <NavLink className="inactive" activeClassName="activeLink" to="/about-us">
      About
    </NavLink>
  </div>

.App-navbar > a {
  display: inline-block;
  color: rgb(54, 127, 175);
}

.App-navbar > .inactive {
  text-decoration: none;
  font-size: 20px;
}

.App-navbar > .activeLink {
  color: rgb(0, 0, 0);
  background-color: rgba(54, 129, 175, 1);
  border-radius: 2px;
}

.App-navbar > a:hover {
  background-color: rgba(54, 129, 175, 0.2);
}

试试这个:

.App-navbar > a:not(.activeLink):hover {
  background-color: rgba(54, 129, 175, 0.2);
}