出于某種原因,React Router Link 正在顯著改變我的 css。有沒有辦法可以消除鏈接中的任何樣式影響?
無鏈接:

帶鏈接:

這是鏈接的代碼。它沒有風格特征。
```
<Link to={`/link/${item.id}`}>
```
樣式={{textDecoration: 'none'}}
uj5u.com熱心網友回復:
使用這個 Npm:https ://www.npmjs.com/package/react-router-bootstrap
import { LinkContainer } from 'react-router-bootstrap'
<LinkContainer to="/foo/bar">
<Button>Foo</Button>
</LinkContainer>
這將與鏈接相同,而不會影響您的 CSS
uj5u.com熱心網友回復:
由于 Link get 已轉換為<a>,您可以使用 css 設定所有樣式<a>并將所有鏈接顏色更改為白色:
a {
color: #FFF;
}
a:hover {
color: #00F
}
或者.link為每個添加一個類Link:
<Link to="/" className="link" />
...
.link {
color: #FFF;
}
.link:hover {
color: #00F
}
uj5u.com熱心網友回復:
有趣的是,將 css 添加到 Link 專案的內部會改變格式。我將影像的 css 從它們以前的內容復制到鏈接內影像的樣式,它看起來是一樣的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/526150.html
標籤:css反应超链接路由器
