在样式组件中是否有扩展createGlobalStyle的方法?



我正在从一个使用createGlobalStyle创建的库中导入GlobalStyle。

有没有办法扩展到…

cont { GlobalStyle } from "another-library";
const exetendGlobal = styled(GlobalStyle)`
select {
background-color: #f60;
}`

我认为createGlobalStyle作为一个方法是不可扩展的。

但是,您可以从其他全局样式中抽象css并包含以获得所需的效果…

SomeGlobalCss.js

import { css } from "styled-components"
Const SomeGlobalCss = css`
body {
background: red;
}
`
export { SomeGlobalCss }

然后导入并包含在全局文件中:

App.js

import { SomeGlobalCss } from "another-library"
const GlobalStyle = createGlobalStyle`
${ SomeGlobalCss } 
body {
background: green;
}
`
export { GlobalStyle }

在这里,你可以包括SomeGlobalCss.js,无论你想…

相关内容

  • 没有找到相关文章

最新更新