【发布时间】:2020-04-14 12:06:43
【问题描述】:
我创建了组件并将 props 传递给样式化的组件,它工作正常,但一开始 prop 它总是出现此错误。
组件
type WelcomeProps = {
image: String,
color: String
}
const StyledWelcome = styled.section`
width: 100vw;
height: 100vh;
background-color: ${props => props.color};
background: ${props => `url(${props.image}) no-repeat center`};
display: flex;
flex-direction: column;
justify-content: center;
`
const WelcomeContainer = styled.div`
width: 1350px;
margin: 0 auto;
`
export const WelcomeFullscreen = (props: WelcomeProps) => (
<StyledWelcome image={props.image} color={props.color}>
<WelcomeContainer/>
</StyledWelcome>
);
用法:
<WelcomeFullscreen image={HomepageImage} color="#000">
【问题讨论】:
标签: javascript reactjs typescript