【问题标题】:Styled-components: React does not recognize the `lineHeight` prop on a DOM elementStyled-components:React 无法识别 DOM 元素上的 `lineHeight` 道具
【发布时间】:2019-11-18 06:58:51
【问题描述】:
const props = {
  lineHeight: 1.4
};

const Out = styled(OutContainer)`
  height: 77px;
`;

Out.defaultProps = props;

还有错误:

警告:React 无法识别 DOM 元素上的 lineHeight 属性。如果您有意希望它作为自定义属性出现在 DOM 中,请将其拼写为小写 lineheight。如果您不小心从父组件传递了它,请将其从 DOM 元素中移除。

我是样式化组件的新手。我错过了什么?

【问题讨论】:

  • 什么是OutContainer?请问可以加代码吗?

标签: javascript reactjs styled-components


【解决方案1】:

您是否尝试过以下解决方案?

const props = {

    style : {
        lineHeight: 1.4
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-15
    • 2020-02-16
    • 2018-12-24
    • 1970-01-01
    • 2019-05-19
    • 2020-03-23
    • 2020-09-02
    相关资源
    最近更新 更多