最近在学习开发Web页面,因为自己一直从事ReactNative开发工作,自然前端页面的学习也是采用了ReactUI框架,昨天在学习的时候,在导入styled-components后设置全局页面的CSS样式时,遇到了以上的错误提示,于是就去这个组件的github官网查看了相关的问题,找到了如下的答案:
// Before:
import { injectGlobal } from 'styled-components';
injectGlobal`
html {
background: red;
}
`
// After
import { createGlobalStyle } from 'styled-components';
export const GlobalStyle = createGlobalStyle`
html {
background: red;
}
`
应该是这个API在最新版本进行移除了,所以找不到了,修改后运行就一切正常了,