【发布时间】:2019-05-17 00:30:47
【问题描述】:
如何将参数传递给样式化组件?
我尝试的是创建一个界面和一个样式化的组件:
export interface StyledContainerProps {
topValue?: number;
}
export const StyledContainer: StyledComponentClass<StyledContainerProps> = styled.div`
position: absolute;
top: `${props.topValue || 0}px`;
`;
那我想这样用:
<StyledContainer
topValue={123}
>
This has a distance of 123px to the top
</StyledContainer>
但它是说props 没有topValue 属性。
【问题讨论】: