react-native - React Native / Styled Components - 覆盖样式化组件样式
问题描述
我正在使用 Styled-Components 来设置我的 React Native 组件的样式,但是,当我为 React.js 组件设置样式时,我习惯使用的一些基本功能无法按预期工作。
我希望有人有解决方案,因为我正在努力从谷歌那里找到答案。
我无法重新设置现有样式组件的样式。以下在 reactjs 中工作正常。
const StyledText = styled.Text`
color: blue;
`
const GreenText = styled(StyledText)`
color: green;
`
// This also doesn't work:
// const GreenText = styled(StyledText)`
// && {
// color: green;
// }
// `
const TextExample = () => (
<View>
<StyledText>This text is blue</StyledText>
<GreenText>This text is also blue, but should be green?</GreenText>
</View>
)
注意:这不仅仅是忽略颜色覆盖,如果我添加任何其他样式规则,它们也会被忽略GreenText
解决方案
推荐阅读
- alfresco - 标题上的 UTF-8 土耳其语字符
- mysql - 无论记录是否存在,获取两个日期之间的最小余额
- azure - Azure:在 Azure Web 应用程序的 Linux 容器中运行非 Web 应用程序
- spring-amqp - 如果接收器/侦听器在单独的项目中,如何使用 listenLatch
- php - 如何在 with() 方法中使用关系?
- angular - 在 Ionic 3 中,使用 Angular 5.2.9,HttpClient 无法为 get 请求设置标头,但可以为 post 请求设置标头
- java - 无法通过 Selenium WebDriver 启动 Chrome 67,ChromeDriver 版本为 67。Eclipse 版本为 Oxygen M2
- c++ - 从文件中读取并在一行中写入 cout
- sql-server - 查找最近的区域
- jquery - 使用 jQuery DateTimePicker 的 ASP.NET MVC Core DateTime 格式