reactjs - 来自 React-router-dom 的样式组件,不适用于样式组件
问题描述
import React, from "react";
import styled from "styled-components";
import { Link } from "react-router-dom";
const StyledLink = styled(Link)`
text-decoration: none;
cursor: pointer;
color: black;
font-size: 14px;
line-height: 22px;
font-weight: 60";
color: #393e46;
letter-spacing: .01em;
`;
const App = () => {
return <StyledLink>some text</StyledLink>
}
export default App;
我正在尝试使用 Styled components 语法从 react-router-dom 设置 Link 组件的样式,但它破坏了我的整个应用程序并且它不能按预期工作。
解决方案
在 Link 组件里面,有一个a标签,你需要给她设置样式:
styled(Link)`
a {
your style here
}
`
推荐阅读
- sql-server - 更改 REG 中的用户 DSN ODBC 设置在 ODBC 管理中没有更改
- java - 当@Qualifier 定义了两个候选对象时,Spring 如何决定注入哪个 bean?
- c++ - 如何修改代码使两个线程保持打印同一行,以便终端显示'A'和'B'交错
- r - 将两个 ggplot 地图叠加在一起
- php - WordPress WC_Meta_Data 完整变体值
- python - Flask - 我登录时 URL 错误
- c++ - sqlite3的问题和makefile中的链接
- google-vision - Google Vision AutoML > 数据集 | csv 中的验证数据不上传
- assembly - 如何在汇编中增加变量?
- asp.net-mvc - 从 MVC 操作重定向到 Web API FileStreamResult