关于injectGlobal被弃用的问题

在styled-component 4.X版本中injectGlobal API除去,用 createGlobalStyle替换了之前的injectGlobal
使用方法:

import { createGlobalStyle } from 'styled-components'

export const Globalstyle = createGlobalStyle` 
  body{
  margin: 0;
  padding: 0;
    background: green;
 }
`

在项目主文件引入

import { Globalstyle } from './style'

然后把Globalstyle以样式组件的方式当作标签引入

function App() {
  return (
    
      
     
  );
}

你可能感兴趣的:(关于injectGlobal被弃用的问题)