繁体   English   中英

样式化组件未应用于该组件

[英]Styled-component is not getting apply to the component

这是我的组件,它没有应用样式。 就我而言,该组件的背景。

import React from 'react';
import styled from 'styled-components'

const TappableButton = (props) => {
  return(
  <div>
    <Button>{props.title}</Button>
  </div>)
}

const Button = styled.button`
  background: "red";
`;

export default TappableButton;

我明白了..问题出在引号上,它没有引号,而只是将“红色”更新为红色。

更改

const Button = styled.button`
  background: "red";
`;

const Button = styled.button`
  background: red;
`;

您不需要在该文本周围加上引号。 演示

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM