我该如何将参数传递给Styled Components?
我尝试创建了一个接口和一个styled组件:
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
属性。
123
没有传递,但默认值被接受了。 - thadeuszlay||
。 - kind user