我试图将这两个样式组件合并为一个。
const CustomInput = styled.input`
width: 150px;
height: 100%;
`;
const CustomTextarea = styled.textarea`
width: 150px;
height: 100%;
`;
最佳答案
使用字符串插值:
const sharedCSS = css`
width: 150px;
height: 100%;
`
const CustomInput = styled.Input`
${sharedCSS}
`
const CustomTextarea = styled.textarea`
${sharedCSS}
`
关于reactjs - 如何合并位于不同基础组件但具有相似样式的两个样式组件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56154027/