TS报错问题
来源:6-5 CSS-in-JS常用工具之Styled-components

宵夜一口吞
2024-01-14
为什么我直接写 type的格式会报错
type ButtonPropsType = {
primary?: boolean
}
const Button = styled.buttonbackground: transparent; border-radius: 3px; border: 2px solid #bf4f74; color: #bf4f74; margin: 0 1em; padding: 0.25em 1em; ${(props: ButtonPropsType) => props.primary && css
background: ‘#BF4F74’;
color: white;}
用官网的传入一个泛型却可以
const Button = styled.button<{ $primary?: boolean; }>`
background: transparent;
border-radius: 3px;
border: 2px solid #BF4F74;
color: #BF4F74;
margin: 0.5em 1em;
padding: 0.25em 1em;
KaTeX parse error: Expected '}', got 'EOF' at end of input: …props => props.primary && cssbackground: #BF4F74; color: white;
}
`;
const Container = styled.divtext-align: center;
render(
Normal Button
<Button $primary>Primary Button
);
1回答
-
双越
2024-01-15
第一,报错信息是什么?截图看看
第二,代码格式化一下,现在看着太乱了
00
相似问题