我试图在一个带有样式的组件中调用一个prop,但是它给了我一个错误:
[ts] Property 'color' does not exist on type 'ThemeProps<any>'.下面是这个问题的代码:
const ButtonContainer = styled.button`
border-radius: 4px;
padding: ${theme.s2};
border: 2px solid ${props => props.color};
background: ${props => props.color};
color: ${theme.textDark};
${(props: { secondary?: boolean }) =>
props.secondary &&
css`
background: none;
color: ${props => props.color};
}
`}
`;并在最后一个props.color实例上显示错误。
你知道如何正确地输入这个实例吗?我想这是为了
${(props: { secondary?: boolean })Typescript版本3.3.3333和样式化组件4.1.3
谢谢
发布于 2019-12-11 07:17:26
尝试以下操作:
color: ${(props: {color: string }) => props.color};希望这能有所帮助。:)
https://stackoverflow.com/questions/54977362
复制相似问题