样式化组件 - 分享 CSS
Styled Components - Share CSS
我有以下风格:
export const oneLine = styled.style`
white-space: nowrap;
`
我正在尝试在这样的样式化组件中使用它:
const Foo = styled.div`
${oneLine}
...
`
但是,未应用该样式。为什么是这样?
其他答案提到使用 styled.css
,但已不存在。
而不是使用 styled.style
使用 css
:
import { css } from 'styled-components'
export const oneLine = css`
white-space: nowrap;
`
其他文件:
const Foo = styled.div`
${oneLine}
...
`
我有以下风格:
export const oneLine = styled.style`
white-space: nowrap;
`
我正在尝试在这样的样式化组件中使用它:
const Foo = styled.div`
${oneLine}
...
`
但是,未应用该样式。为什么是这样?
其他答案提到使用 styled.css
,但已不存在。
而不是使用 styled.style
使用 css
:
import { css } from 'styled-components'
export const oneLine = css`
white-space: nowrap;
`
其他文件:
const Foo = styled.div`
${oneLine}
...
`