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

时间:2018-12-12 06:11:59

标签: reactjs styled-components

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

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;

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

更改

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

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

您不需要在该文字两边加上引号。 demo