我如何在样式组件、情感中使用嵌套的 css 模板文字
how can I use nested css template literals in styled-components, emotion
const someStyle = css`
colors : ${({theme}) => theme.colors.primary;
${(props) => props.active ? css`
background-color: ${({theme}) => theme.colors.backgroundColorActive};
`}
`
const SomeButton = styled.div`
${someStyle}
`
我可以使用嵌套在另一个 css 模板文字中的 css
模板文字吗?
使用简单的模板字符串更容易:
const someStyle = `
color: ${({theme}) => theme.colors.primary;
${(props) => props.active ? `
background-color: ${({theme}) => theme.colors.backgroundColorActive};
`}
`
const SomeButton = styled.div`
${someStyle}
`
const someStyle = css`
colors : ${({theme}) => theme.colors.primary;
${(props) => props.active ? css`
background-color: ${({theme}) => theme.colors.backgroundColorActive};
`}
`
const SomeButton = styled.div`
${someStyle}
`
我可以使用嵌套在另一个 css 模板文字中的 css
模板文字吗?
使用简单的模板字符串更容易:
const someStyle = `
color: ${({theme}) => theme.colors.primary;
${(props) => props.active ? `
background-color: ${({theme}) => theme.colors.backgroundColorActive};
`}
`
const SomeButton = styled.div`
${someStyle}
`