【问题标题】:Not able to use relative values in React Native Styled Components无法在 React Native Styled Components 中使用相对值
【发布时间】:2022-04-29 21:36:46
【问题描述】:

从 react native styled-components 文档中,我看到使用 EM 值代替了通常的 px。但是,当我尝试编译使用 REM 值的项目时,它会失败并给我一个错误“预期数字得到字符串”。
有什么我想念的吗?样式组件不支持 REM 值吗?这是我的代码

const TitleG1_1 = styled.Text`
    font-size: 1.2rem;
    padding: 0;
    margin: 0;
    color: #3a3e59;
`;

谢谢。

【问题讨论】:

标签: javascript html css react-native styled-components


【解决方案1】:

确定样式组件支持 rem 作为度量。问题应该是您如何定义标题。我会解释的,试试这个:

const TitleG1_1 = styled(Text)`
    font-size: 1.2rem;
    padding: 0;
    margin: 0;
    color: #3a3e59;
`

【讨论】:

    猜你喜欢
    • 2022-09-25
    • 2018-03-06
    • 2020-01-08
    • 2021-05-09
    • 2020-10-19
    • 2021-07-13
    • 2022-01-04
    • 2018-10-20
    • 2019-08-06
    相关资源
    最近更新 更多